Reputation: 43
I've got to rename our application and would like to search all strings in the source code for the use of it. Naturally the app name can appear anywhere within the strings and the strings can span multiple lines which complicates things.
I was using (["'])APP_NAME
to find instances at the start of strings but now I need a more complete solution.
Essentially what I'd like to say is "find instances of APP_NAME enclosed by quotes" in regex speak.
I'm searching in Xcode in case anyone has any Xcode-specific alternatives...
Upvotes: 2
Views: 250
Reputation: 627371
You may use
"[^"]*APP_NAME[^"]*"|'[^']*APP_NAME[^']*'
See the regex demo.
Note that this regex is based on alternation (|
means OR) and negated character classes ([^"]*
matches any 0+ chars other than "
).
Or, alternatively:
(["'])(?:(?!\1).)*APP_NAME.*?\1
See this regex demo. The pattern is a bit trickier:
(["'])
- captures "
or '
into Group 1(?:(?!\1).)*
- any 0+ occurrences of a char that is not equal to the one captured into Group 1APP_NAME
- literal char sequence.*?
- any 0+ chars other than line break chars but as few as possible`up to the first occurrence of...\1
- the value captured into Group 1.Upvotes: 2