help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with Emacs Regex


From: Barry Margolin
Subject: Re: Help with Emacs Regex
Date: Wed, 16 Jul 2003 15:41:57 GMT

In article <mailman.121.1058369387.8231.help-gnu-emacs@gnu.org>,
Hortman, Mark <markh@JohnsAuto.com> wrote:
>I have a rather simple regex question or two I was hoping someone could help
>me with.
>
>I need to match lines that do not begin with " and three numbers, so
>
>"300
>"400
>"50a
>abc
>500
>
>I need to match all lines but the first two.  I have tried
>^[^"0-9\{3\}]
>
>Which I, being a regex, emacs newbie interpret as search for all beginning
>of lines that
>dont have a " and then three numbers.  What gives?

[^<stuff>] matches a *single* character that isn't any of the characters
in <stuff>.  To do what you want, you need:

^\([^"]\|.[^0-9]\|..[^0-9]\|...[^0-9]\)

Note that if you're using the regexp with a command like M-x keep-lines, an
easier solution is to use M-x delete-matching-lines with a simpler regexp:

^"[0-9]\{3\}

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]