in reply to Re: Extract substring from string with no whitespace using regexp?
in thread Extract substring from string with no whitespace using regexp?

...where the parentheses are numbered by the position of the left parentheses, so "abc" =~ /((a)b(c))/ will set $1 to "abc", $2 to "a", and $3 to "c".

If you use a regex that has parentheses in list context, the substrings are returned in a list, and can be used directly:

my ($abc, $a, $c) = "abc" =~ /((a)b(c))/

see perlop for more information about m// and s/// and what they return and how flags like //g affect them.

  • Comment on Re: Re: Extract substring from string with no whitespace using regexp?
  • Download Code