- or download this
$_ = "a b=c";
/(a)(.*)(?:b=(\w))?/;
printf "\$2 is [%s]\n", defined $2 ? $2 : "undefined";
printf "\$3 is [%s]\n", defined $3 ? $3 : "undefined";
- or download this
$2 is [ b=c]
$3 is [undefined]
- or download this
$_ = "a b=c";
/(a)(.*?)(?:b=(\w))?/;
printf "\$2 is [%s]\n", defined $2 ? $2 : "undefined";
printf "\$3 is [%s]\n", defined $3 ? $3 : "undefined";
- or download this
$2 is []
$3 is [undefined]