Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pattern matching question

Status
Not open for further replies.

loosecannon1

Programmer
Feb 19, 2002
55
US
I'm trying to get "admin" out of the following:

$env_var = "iw_role=admin; iw_user=2z60z1;";
$env_var =~ m/iw_role=(.*);.*/;
print $1;


Problem is the string "admin; iw_user=2z60z1" is stored in $1 not "admin". But if I take the second semicolon off like: $env_var = "iw_role=admin; iw_user=2z60z1";
it works.

Can anyone explain why this is happening?

 
Thanks jaa, great link!

This works:
$env_var =~ m/iw_role=(.*?);/;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top