why does this work, why doesn't this work?n is it BREorERE?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
bintin
Posts: 14
Joined: Tue Jun 01, 2010 1:33 pm

why does this work, why doesn't this work?n is it BREorERE?

Post 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
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
bintin
Posts: 14
Joined: Tue Jun 01, 2010 1:33 pm

Post 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.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To use the ERE-ish style, select
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Post Reply