Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks!
I need your wisdom in the world of regular expressions.
What I want to do is this. Out of the following string:

#total mean for 530.2 nm = 411.67 W/m**2, dev= 0.2%

I need to extract the highlighted numeric value only.
Although I am, in this instance looking for a quick and efficient solution to this scenario, I would like to learn more. So... if anyone has an excellent link to a simple yet powerful regex tutorial I would greatly appreciate it.
And.... no, this is definitely not homework. Thank you in advance for your wisdom, for at the moment my knowledge of regexes is limited, soon I hope for it to grow.

Replies are listed 'Best First'.
Re: regexp help needed
by ikegami (Patriarch) on Oct 17, 2006 at 15:13 UTC
    Sorry, the only link I have is to the Perl docs, perlre.
    my ($mean) = $str =~ /total mean for ([-+0-9.]+)/;
Re: regexp help needed
by shmem (Chancellor) on Oct 17, 2006 at 15:16 UTC
Re: regexp help needed
by davorg (Chancellor) on Oct 17, 2006 at 15:45 UTC

    I recommend Regexp::Common.

    use Regexp::Common qw(number); $_ = '#total mean for 530.2 nm = 411.67 W/m**2, dev= 0.2%'; if (/$RE{num}{real}{-keep}/) { print "$1\n"; }
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg