I inherited an Objective C project with a bunch of methods named things like "getMerchantSettings". Of course in Objective C (unlike Java) it is unconventional to use the word "get" in the method name for getters, since it makes them incompatible with auto-synthesized property getters, etc.
I can globally search my project to find all such offending method names using a regex pattern like get([A-Z])
. In SublimeText I can replace all these with \L$1
and it will change everything like "getMerchantSettings" to just say "merchantSettings"; the \L will make the "M" character into the lower case "m" when it replaces it.
However in XCode's version of regex, \L and \l both do not work. What is the regex replacement pattern to use in XCode 8 to make it change the case of whatever it's replacing? Would prefer not to have to use a separate text editor for things like that. Thanks!
The Regex. Replace(String, String, MatchEvaluator, RegexOptions) method is useful for replacing a regular expression match if any of the following conditions is true: If the replacement string cannot readily be specified by a regular expression replacement pattern.
Xcode displays the results of the search, but it doesn't automatically replace the text. To replace the text for a single result, select it and click the Replace button. To replace the text for all results, click Replace All.
XCode 8 can't do that for you unfortunately. As you have perl, you can open a terminal, cd
to your repo and run this:
find . -name *.[EXTENSION] -exec perl -i.bak -pe 's/get([A-Z])/\L$1/' {} \;
This will generate a backup of your files (.bak
files) and change your getters to the needed format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With