Is it possible to extract the nth match in a string of single-quoted words?
use strict; use warnings; my $string1 = \"\'I want to\' \'ex
The match-g operator evaluated in an array context yields an array of matches. Therefore:
@matches = $string =~ /'(.*?)'/g; $matches[$index-1];
is one way to get what you want.