Page 1 of 1
why does this work, why doesn't this work?n is it BREorERE?
Posted: Mon Oct 04, 2010 5:19 pm
by bintin
why doesn't \(\r\n\)\{3,\} match
but this \(a\)\{3,\} does?
how would I get \(\r\n\)\{3,\} to work?
I see + is recognized, so wouldn't that be POSIX ERE? Why does it act like POSIX BRE for escaping ( ) and { } ? and ERE in having +. Is there a name for this if it's not posix BRE or ERE?
i'm using textpad v5
Posted: Mon Oct 04, 2010 9:00 pm
by ben_josephs
There are two unrelated issues here.
1. \(\r\n\)\{3,\} -- or (\r\n){3,} using "Posix" syntax -- doesn't work for two reasons:
a. TextPad's regex recogniser never sees a carriage return: TextPad handles all line endings (LF, CR or CR-LF) in the same way, and \n matches any of them. \r doesn't match a CR; it matches a plain r.
b. TextPad's regex recogniser doesn't allow a \n to be quantified with * or + or {m,n}, or to be contained in a parenthesised expression. So you can't match an arbitrary number of newlines.
2. TextPad's use of the tem "Posix" in the context of regular expressions is incorrect. It merely refers to the use of the symbols (, ), |, { and } as operators when they stand alone and as literals when the are escaped with backslashes, rather than the other way round. The same engine underlies both syntactic styles. This engine supports +, even though Posix BREs (basic regular expressions) don't.
Posted: Tue Oct 05, 2010 12:39 am
by bintin
ta.. one point though..
ben_josephs wrote:use of the symbols (, ), |, { and } as operators when they stand alone and as literals when the are escaped with backslashes, "
() and {} in textpad v5 anyway, seem to be literals when stand alone and operators when they are escaped.
(a) matches (a)
\(a\) matches a
(so like BRE with respect to () {} )
How do I change the color it uses when I click find and it matches something? its a bit faint.
Posted: Tue Oct 05, 2010 6:16 am
by ben_josephs
To use the ERE-ish style, select
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax