in reply to Re: how do i get the 2nd line when the 1st is matched
in thread how do i get the 2nd line when the 1st is matched

Are you sure that pattern is what you want? It demands that the string be followed by any amount of whitespace (including none!), followed by at least one character of non-whitespace which will be capture. Here are some things it will match:

$text = "whatever_you_already_havefoobar\n"; # $1 eq "foobar" $text = "whatever_you_already_have foo\nbar"; # $1 eq "foo" $text = "whatever_you_already_have\nfoobar"; # $1 eq "foobar" $text = "whatever_you_already_have\nfoo bar"; # $1 eq "foo"

You probably meant something more along the lines of

/whatever_you_already_have.*\n(.*)/

Or if you want to do it using /s for other reasons,

/whatever_you_already_have[^\n]*\n([^\n]*)/s

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^3: how do i get the 2nd line when the 1st is matched
by ikegami (Patriarch) on Aug 17, 2004 at 14:43 UTC
    Aye, the solution can be adapted to more complex input if required. Thanks for expanding on it.