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

I am trying get the following out put using the below input but nothing gets printed

INPUT:Info: Product Line is MMS 3.3

OUTPUT: MMS 3.3

foreach my $match (@verifysrclog) { if ( $match =~ /Info: Product Line is (\w+)/ ) { $product_line = $1; print "$product_line\n"; } }

Replies are listed 'Best First'.
Re: Regex help for printing alphanumeric
by toolic (Bishop) on Oct 28, 2011 at 02:13 UTC
    Why do you expect the 3.3 to be printed? \w does not match whitespace. I suggest you read perlre before posting again:
    use warnings; foreach my $match ('Info: Product Line is MMS 3.3') { if ( $match =~ /Info: Product Line is (\w+)/ ) { $product_line = $1; print "$product_line\n"; } } __END__ MMS
Re: Regex help for printing alphanumeric
by sumeetgrover (Monk) on Oct 28, 2011 at 10:40 UTC
    Hi there, 'MMM 3.3' is certainly not alphanumeric. Alphanumeric could be defined as a 'sequence' of alphabets combined with digits. However, if you do wish to match this in a regexp, below is the specific regexp for this particular pattern only, i.e. alpha float-number:
    /[A-Za-z]+ [0-9]+\.[0-9]+/

    Hope this helps! Sumeet.

      Actually my input is wrong...there is no space ,instead there is a ".",it still doesnt print,basically I want to print anything after Info: Product Line is

      use warnings; foreach my $match ('Info: Product Line is MMS.3.3') { if ( $match =~ /Info: Product Line is (\w+)/ ) { $product_line = $1; print "$product_line\n"; } }