[Ilugc] regular expression the check if a string is absent
- From: freedomyug@xxxxxxxxx (Gourav Shah)
- Date: Mon Jun 8 19:15:07 2009
I am trying to build a regular expression that will find all strings that
do
not start with '2009/'. Any clues?
I am assuming you could use grep here, if not, please specify how you intend
to do the pattern matching.
grep has a option to invert match, here is a snip from manpage,
...
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
(-v is specified by POSIX.)
so if its grep, you could use, grep "^2009/" <FILENAME>
e.g.
$ cat >> /tmp/t.txt
snfgd
fdnbfognbof errgirnbinr
kjfnfbjgnb 434fgv 54y 5obn
2009/ rgerigbir nr
vrgnbn
2009/ y fdgovrf23 3gp 4
bgfbog
232234
565
2009
regtrgm ^[[A^[[A
2009 enfvfrnv evirvir
vornbtr
$ grep "^2009/" /tmp/t.txt
2009/ rgerigbir nr
2009/ y fdgovrf23 3gp 4
$ grep -v "^2009/" /tmp/t.txt
snfgd
fdnbfognbof errgirnbinr
kjfnfbjgnb 434fgv 54y 5obn
vrgnbn
bgfbog
232234
565
2009 enfvfrnv evirvir
vornbtr
Thanks
Gourav
Other related posts: