I tried one final time with non-capturing parentheses i.e. (?: to no avail.
This works just fine however:
perl -i -p -e '@matches = m/\d{2}\t\d{2}\t\d{2}/g; s/.*//g; print"@matches\n"'
Retrieve, delete what's left, and rewrite what's to be kept. It should now
work everytime all the time. Crude but effective. My (result)/(time spent)
ratio would have been lower without your help. I stumbled over the ; inside
of the ''s for one.
Thanks very much.
Stu
> >
> > > perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st
> > thing that I tried; it doesn't work. It was initially easy but
> > different things kept appearing that forced me to use > 1
> > statements on the command line. Negating what I want seems like
> > it ought to be simple.
>
> There are a couple of things here:
>
> 1) s/// requires a string to replace the match with. you haven't
> supplied one. This should produce a syntax error.
>
> 2) You've anchored your patttern at the beginning of the string. This
> makes /g a no-op; you're pattern can't possibly match more than once,
> because '^' can only appear once.
>
> 3) s/// replaces whatever is matched on the left side with whatever
> you put on the right side, and leaves the rest of the string
> untouched. You need to specify what you don't want, as well.
>
> If you know that your will always have a single occurance at the
> beginning of the line, use something like:
>
> s/^(\d\d\t\d\d\t\d\d).*/$1/
>
> I think we're about at the end of how much we can help based on what
> you've given us. Show us a couple of the complete command lines you've
> tried (so we can see what your ultimate goal is) and some sample data.
>
> -- jay
--
_______________________________________________
Search for businesses by name, location, or phone number. -Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>