in reply to regexp: extracting info

The problem I have with this string is a little bit miss understood. Assume you have a very large multi line string, and only one line looks likt describe above!
Thanks for the tut suggestions!

Luca

Replies are listed 'Best First'.
Re^2: regexp: extracting info
by pKai (Priest) on Dec 23, 2005 at 15:51 UTC

    If you want to match a line in a multiline string, you need the m-modifier and the line-begin (^) and line-end ($) indicator.
    You can read about those in the perldocs already meantioned.

    Going with your specification so far:

    I need to extract "10" however there might be 2 or 3 words preceding.
    and
    a very large multi line string, and only one line looks likt describe

    Going with this, i would suggest:

    $str =~ /^(?:\w+\s+){2,3}10$/m

    There might be other restrictions you want to place on your match (more specific whitespace preceding the 10? optional whitespace (or even other words) after the 10?)

    We don't know. You have to make up your mind, what the appropriate pattern is.