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
You can try:
sub extract_quoted { my ($string, $index) = @_; while($string =~ /'(.*?)'/g) { $index--; return $1 if(! $index); # return $1 if index became 0. } return; # not found - returns undef or () depending on context. }