Use regex to find specific string not in html tag

后端 未结 8 1105
温柔的废话
温柔的废话 2021-02-05 08:53

I\'m having some difficulty with a specific Regex I\'m trying to use. I\'m searching for every occurrence of a string (for my purposes, I\'ll say it\'s \"mystring\") i

8条回答
  •  死守一世寂寞
    2021-02-05 09:18

    A quick and dirty alternative is to use a regex replace function with callback to encode the content of tags (everything between < and >), for example using base64, then run your search, then run another callback to decode your tag contents.

    This can also save a lot of head scratching when you need to exclude specific tags from a regex search - first obfuscate them and wrap them in a marker that won't match your search, then run your search, then deobfuscate whatever is in markers.

提交回复
热议问题