Re: Regular Expression in Xcode Editor: newlines+whitespace
Re: Regular Expression in Xcode Editor: newlines+whitespace
- Subject: Re: Regular Expression in Xcode Editor: newlines+whitespace
- From: Chris Espinosa <email@hidden>
- Date: Sun, 2 Nov 2008 20:38:31 -0800
On Nov 2, 2008, at 7:42 PM, Jerry Krinock wrote:
Whenever I need to do any serious regex search/replace I have to
switch to BBEdit because I can never get Xcode's to find expected
results. Solving the following simple mystery might be a big help:
Find: \n This finds a newline. Great.
Find: \s This finds a whitespace. Great.
Find: \s*\n This finds trailing whitespaces at end of lines. Great.
But
Find: \n\s
Expected Result: Should find any newline followed by a
whitespace -- roughly, any indented line.
I have lots of those!
Actual Result: NSBeep(). Never finds anything.
How can I get my expected result?
Xcode doesn't do cross-line regex matches. (Neither does grep, for
that matter.)
If you are looking for a pattern at the beginning of the line, use the
regex "beginning of line" marker, "^". And of course you want to find
runs of whitespace, not just the first instance, so the regex you
want is
^\s+
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden