in reply to Re: Capture groups
in thread Capture groups

The regex above will capture trailing spaces in the $1 variable ([A-Za-z\s]*). It's probably easier to just get rid of them after the match, with $match[0] =~ s/\s+$//; otherwise you'll need a fancier regex :-)

Replies are listed 'Best First'.
Re^3: Capture groups
by ww (Archbishop) on Mar 05, 2008 at 12:33 UTC

    IMO, it's "easier" to get rid of the trailing spaces (not required by OP, so Joost's correct answer is perfectly serviceable for the specs given) in the original match:

    if ( $string =~ /([A-Za-z]*\s[A-Za-z]*)\s+([0-9]{1,2}[%])/ ) { print $1 . "\n" . $2; # ^ } else ...