[plug] Grep not following my regex

Tim weirdit at gmail.com
Tue Sep 15 09:11:18 WST 2009


I have been doing some string extraction for an application I've
written. I needed to extract a number (with decimal point) from a one
line string. I had the grep working, but then having moved to another
computer, it stopped working. I did some debugging on the computer I'd
moved to, to see why my application no longer worked, and narrowed it
down to this grep.
egrep -o '[0-9.]*'

By changing the grep to the following, I managed to get it working again.
egrep -o '[0-9.]+'

Now I know that the + may make more sense now, by forcing a match, but
I can't see why the first regex stopped working.

The string it's matching against is:
You currently have 347.454MB remaining
and obviously it just pulls out the 347.454.

Other than bash stealing the * from the grep (which I am sure
shouldn't be happening due to the quotes), can someone let me know why
the first regex stopped working? (Also, I was moving from an Ubuntu
system to a Fedora system)

Thanks

Tim
-- 
Timothy White - Somewhere in Australia



More information about the plug mailing list