in reply to Re^2: Defining Characters in Word Boundary?
in thread Defining Characters in Word Boundary?
is there a meaningful difference between (?![a-z]) and (?=[^a-z])? is the former recommended?
Yes, they're different regular expression patterns that match different things. (?![a-z]) asserts "not followed by any of the characters from 'a' through 'z', which includes not being followed by any character." (?=[^a-z]) asserts "followed by a single character that is not any of the characters from 'a' through 'z'." The former is a negative assertion; the latter is a positive assertion.
In your case, (?![a-z]) is what you would want to use.
[PerlMonks posting tip: Enclose Perl code in <code></code> tags, even code within paragraphs.]
UPDATE: Removed color.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Defining Characters in Word Boundary?
by AnomalousMonk (Archbishop) on Jan 20, 2011 at 23:28 UTC | |
by Jim (Curate) on Jan 21, 2011 at 01:06 UTC | |
by ikegami (Patriarch) on Jan 21, 2011 at 01:24 UTC | |
|
Re^4: Defining Characters in Word Boundary?
by Anonymous Monk on Jan 20, 2011 at 18:08 UTC | |
by Jim (Curate) on Jan 20, 2011 at 19:40 UTC | |
by Anonymous Monk on Jan 21, 2011 at 05:40 UTC | |
by Jim (Curate) on Jan 21, 2011 at 17:55 UTC |