On Wed, Oct 08, 2008 at 01:56:43PM -0400, Bull Durham wrote:

> Here's my GREP pattern: ^(.)([^\1])[^\1\2]\r
> 
> If I understand this right, the (.) is the first character, then ([^ 
> \1]) is any character that is not the same as the first, then [^\1\2]  
> is any character that is not the same as the first or second. (I  
> enclosed the expression in ^ ... \r to exclude three-letter sub- 
> strings.)

Character classes, denoted by square brackets, have a completely separate
syntax from the main regular expression syntax.  A character class is
simply a list of individual characters.  [^\1] does not mean 'match any
character not matched by the first set of capturing parentheses'.  It means
'match any character other than 1'.

To do what you want, you should use a negative look-ahead.  A negative
look-ahead succeeds if the sub-expression does not match at this point in
the string.  It does not consume any of the string.

Here's how that would look in this case:

^(.)(?!\1)(.)(?!\1|\2)(.)\r

(?!\1) makes sure that the next part of the string does not match whatever
was captured in \1.

Ronald

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to "[EMAIL PROTECTED]" 
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to