in reply to Regex String Matching

. . .I get a runtime error saying that $1 is uninitailised.

You need to use parentheses to capture the match.

$str =~ /str=([a-zA-Z]+)/

Since you mention you want everything up to the next '&' you might be better off with a regex that does what you mean:

$str =~ /str=([^&]*)/
Edit: Fixed that typo. Arien++
-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re(2) Regex String Matching
by Arien (Pilgrim) on Sep 09, 2002 at 04:55 UTC
    $str =~ /str=([^&])*/;

    There's a typo in that regex, you want the star inside the parens. (You are now putting the last non-ampersand following str=, if any, into $1.)

    $str =~ /str=([^&]*)/;

    — Arien