The answer is that the [^a] phrase means any character other than 'a', but it still must match one character. Since the string 'at' only has 2 characters, there is no character at all to match.
So what is actually called for is a negative-lookbehind: /(?<!a)at/ that ensures 'at' isn't preceded by an 'a' character, it will still match 'at' when it begins in the first character position of a string.
/[^a]?at/ Would behave as you expected the original regex to behave. Update: ugh, this was a little optimistic, it will do the wrong thing with 'aat' now.
In reply to Re: little regex question
by Loops
in thread little regex question
by anaconda_wly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |