Sometimes you may have to use Textwrangler, SublimeText, Notepad++, or whatever IDE to search for a string which contains something commonly found outside of a string. For example, what if you want to find a string that in a Python file that had a hash symbol. In this case you could use the following regular expression:
"([^\\\"]+|\\.)*#([^\\\"]+|\\.)*"

In general, the regular expression can look like the following to match any string literal:
"([^\\\"]+|\\.)*"|'([^\\\']+|\\.)*'

Of course this regular expression really depends on the language that you are dealing with. Some languages such as VB require strings to be surrounded in double-quotes and each double-quote is escaped by placing another double-quote character in front of it.

Categories: Blog

Leave a Reply

Your email address will not be published. Required fields are marked *