Find hardcoded strings but not file names (Xcode, Regex help)

I am looking for all hardcoded strings in my application so that I can localize them. I am currently using regular express search for @ "[^"] + "as suggested in this answer: Searching hard-coded text in xcode

The problem is that I want to find only some lines in this format. For example, I want to exclude [UIImage imageNamed: @ "string"] and NSLog (@ "Log string"). I believe that the easiest way to do this is to find the format string @ "[^"] + ", until the previous characters include NSLog (or imageNamed :) or a few other things that I will enter manually.

How to write a regular expression that excludes these cases?

+7
string regex ios objective-c xcode
source share
2 answers

You can use a negative lookbehind to rule out these cases:

(?<!(imageNamed:|NSLog\())@"[^"]+"

+10
source share

For Swift Project

In Xcode> Search> Find> Regular Expression - enter "[a-zA-Z0-9]+"

enter image description here

0
source share

All Articles