Why doesn't this simple regex match what I think it should?
Posted
by Kevin Stargel
on Stack Overflow
See other posts from Stack Overflow
or by Kevin Stargel
Published on 2010-04-06T17:56:26Z
Indexed on
2010/04/06
18:23 UTC
Read the original article
Hit count: 300
I have a data file that looks like the following example. I've added '%' in lieu of \t
, the tab control character.
1234:56% Alice Worthington
alicew% Jan 1, 2010 10:20:30 AM% Closed% Development
Digg:
Reddit:
Update%% file-one.txt% 1.1% c:/foo/bar/quux
Add%% file-two.txt% 2.5.2% c:/foo/bar/quux
Remove%% file-three.txt% 3.4% c:/bar/quux
Update%% file-four.txt% 4.6.5.3% c:/zzz
... many more records of the above form
The records I'm interested in are the lines beginning with "Update", "Add", "Remove", and so on. I won't know what the lines begin with ahead of time, or how many lines precede them. I do know that they always begin with a string of letters followed by two tabs. So I wrote this regex:
generate-report-for 1234:56 | egrep "^[[:alpha:]]+\t\t.+"
But this matches zero lines. Where did I go wrong?
Edit: I get the same results whether I use '...'
or "..."
for the egrep
expression, so I'm not sure it's a shell thing.
© Stack Overflow or respective owner