in reply to Regex problem

Using a regex rather than split,

my @values = $line =~ m{(\d+(?:\.\d*)?)(?=\s*,|\z)}g;

seems to do the right thing.

I hope this is of use.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Regex problem
by halley (Prior) on May 10, 2007 at 17:09 UTC
    The m//g operator, and the split() function, are opposite sides of the same coin. If it's easier to describe the things you want to keep, use a match. If it's easier to describe the things you want to discard, use a split.
    m{(\d+(?:\.\d*)?)(?=\s*,|\z)}g
    split /,/
    Which seems easier to write, read, and maintain?

    --
    [ e d @ h a l l e y . c c ]