I'm confused about a couple things.

First, the grep not only will match "N15" which is invalid, and not match "N15 4RC" which is valid, but it will not match "N15 4RCCCC" which is invalid.

Second, what does the ".+" do? Removing that causes only a blank line to be matched.

The grep pattern is seemingly stating: "if the first characters do not match the following pattern, and, there are some characters," then the result of the grep pattern is True so highlight that line or conduct the replace.

The grep pattern (with the negation) matches neither:

A valid post code followed a carriage return, does match the pattern and is not followed by any non-space or non-tab characters. A valid post code followed by other characters, does match the pattern and is followed by non-space characters.

Just trying to understand the grep patterns.

Thanks,
Randy



On 26/11/2006, at 11:07 , Ronald J Kimball wrote:

On Sat, Nov 25, 2006 at 11:58:37PM +0000, Richard A Clarke wrote:
Given a grep pattern, how do I find exceptions in my file that _don't_ fit
the pattern?

A valid postcode matches this pattern:
^([A-Z]{1,2}[\d]+ \d[A-Z][A-Z])$

I'd like to step through the file finding the next instance that DOESN'T
match my pattern - how do I do that?

Here's one way to do it:

^(?![A-Z]{1,2}[\d]+ \d[A-Z][A-Z]).+$

Ronald

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>


--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to