I am trying to setup a single regex to breakdown the following lines:
Jerry 2.7 4 4.5 mon Mark -14 -10.75 -10 new
With
/(\w+)\s+(-?\d+.\d+)\s+(-?\d+.\d+)\s+(-?\d+.\d+)\s+(\w+)/;
What am I doing wrong?
You are not showing us a complete program that generates some other output than the output you were expecting.
A couple of observations besides that:
- Not all numbers at those lines include digits before and after a decimal point.
- The '.' character has a special meaning when used in a regex outside a character class, and should therefore be escaped.
This code:
(-?\d+(?:\.\d+)?)
would match any of those numbers.
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>