Re: regular expression and not form
- From: "Xicheng Jia" <xicheng@xxxxxxxxx>
- Date: 21 Jul 2006 08:49:43 -0700
caiqian@xxxxxxxxx wrote:
Hi,
Xicheng Jia wrote:
caiqian@xxxxxxxxx wrote:
Hi,
How can I express "match any string except 'ABC'" in regular
expression?
If you can use tools supporting Perl-compatible regex, like Perl,
python, Ruby, then, the regex can be written as:
^(?!.*ABC)
The following command prints all lines which dont contain the string
"ABC" in *myfile*
perl -ne 'print if/^(?!.*ABC)/' myfile
Xicheng
Works fine. I am still wondering if there is a way to do the following
in Bash use =~, and my grep does not support -P (perl regular
expression) yet.
Qian
grep -v ABC
:-)
Xicheng
.
- References:
- regular expression and not form
- From: caiqian
- Re: regular expression and not form
- From: Xicheng Jia
- Re: regular expression and not form
- From: caiqian
- regular expression and not form
- Prev by Date: Re: regular expression and not form
- Next by Date: Problem while copying the file
- Previous by thread: Re: regular expression and not form
- Next by thread: Re: regular expression and not form
- Index(es):
Relevant Pages
|