开发者

Xcode lazy regular expression

开发者 https://www.devze.com 2022-12-21 09:17 出处:网络
I\'m trying to replace something like this: NSSomeFunction(@\"some var\", @\"another one\") With: NSSomeOhterFunction(@\"some var\")

I'm trying to replace something like this:

NSSomeFunction(@"some var", @"another one")

With:

NSSomeOhterFunction(@"some var")

In Xcode. So these are source files... I bet the regular expression will look something like this:

NSSomeFunction\((.*), .+\)

But I need this to be lazy. Otherwise .+) will match the last parenthesis occurrence rather than the first (for example both parenthesis in the end would be replaced with a single one given this string: "NSLog(@"%@", NSSomeFunction(@"hey", @"lol"))" ).

How to do laz开发者_高级运维y search like this? I think you can do this in pearl using the modifier /U (ungreedy). Though Xcode does not seem to support that.


usually the ? will indicate non-greedy match, so for .+) you would use .+?)

0

精彩评论

暂无评论...
验证码 换一张
取 消