--- In email@example.com
, Sheri <silvermoonwoman@...> wrote:
> On 1/28/2011 5:57 PM, mycroftj wrote:
> > I HOPE this is not something I should easily see.
> > I am using NTL 6.2
> > This is the FIND command, not a clip.
> > I wanted a regular expression to find lines that did not begin with a comma.
> > I did NOT mess around with look aheads because I thought ^[^,] would work but each click of the FIND NEXT button finds every character on a line up to the end of the line or a comma. ^, finds each line that DOES begin with a comma so why doesn't the negation work?
> > In a similar way, why does ^[adfg] find the first a in asefasdf (which I expected) and the first d in the next line (which I expected) but also all the rest of the chars in dgdfgdf? I thought this would find a,d,f or g if they were the first char on a line.
> > Thanks for explaining!
> > Joy
> Hi Joy,
> If you are looking for whole lines that begin with one of those
> characters, the cursor needs to start at the beginning of a line and
> your pattern needs to match the entire line. Otherwise, after a match,
> you need to move the cursor to the beginning of the next line before
> re-running. The metacharacter "^" matches at the beginning of each line
> and also at the beginning of the subject passed for matching. For the
> Find function, after your pattern has matched, the next subject getting
> tested begins with the next character following the match.
> Another possibility would be to look for the characters only when they
> follow a line break e.g.,
> Obviously that can't possibly match at the start of the first line.
> This is an area where NoteTab Pro has a different behavior (which
> actually is not to my liking). If NoteTab Pro notices a pattern begins
> with "^" it moves to the beginning of the next line before testing. So
> NTP makes it appear that ^ matches only at the beginning of a line.
> There are workarounds to keep NTP from doing that.
> There are other functions (e.g., Replace All) that treat the portion of
> the document following the cursor as one subject. If you use one of
> those functions, your pattern will behave more like you expected.
> However you should ensure that the cursor is at the top of the document
> or at the beginning of a line when you start one of those functions.
> Alternatively you can enable the Whole document (aka "All") option.
> Hope this helps explain what you saw.
Thanks so much for the explanation. I've been reading and studying and have never noticed any place that points out what you said about the metacharacter "^" will also match at the beginning of the subject passed for matching and not just at the start of a line.
When I manage a difficult regexp string and then fail on a 'simple' one, I start to wonder if it's my computer or myself. So far, it's always been myself and mostly concerning strange quirks of regexps I seem to be good at stumbling upon.