Zembower, Kevin wrote:
I'm trying to filter on the first character after the eighth tab but I'm
matching this line and don't know why:
[EMAIL PROTECTED]:/var/www/centernet/htdocs/ldap_auth$ perl -ne 'print if
/^(.*?\t){8}T/' /tmp/PeopleFinderData.txt |cat -vet
397^IRxxxxx^ITxxx^IT^I^ITTR^Itrxxxxx^IProgram officer
[EMAIL PROTECTED]
[EMAIL PROTECTED]:/var/www/centernet/htdocs/ldap_auth$
I piped it through 'cat -vet' so the tabs show up clearly as '^I's. This
line shouldn't match, because the first character after the eighth tab
is an A and not a T. I used non-greedy matching of the .*?, so I thought
it would work properly. Would anyone explain to me why it's not working
the way I thought it should?
(.*?\t) says to match *any* character (including a "\t" character) zero or
more times followed by a "\t" character so it will keep searcing until it
finds the pattern "\tT" anywhere after the first seven tabs.
I'd also welcome suggestions of better ways
to write this code.
/^(?:[^\t]*\t){8}T/
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/