我正在尝试捕获带连字符的单词中所有连字符的位置,以便我可以加载包含这些连字符位置的哈希值(在文本中,而不是单词中)。目前,我正在尝试在非捕获组内使用捕获组……但它只捕获最后一个连字符。
my $word = shift (@_);
my $word_start_pos = shift (@_);
my $text = shift (@_);
my $dash_pos = 0;
my $exp = 0;
my $pos = 0;
my $test_char = '';
if ($word =~ /^(?:[\p{L&}0-9\.\'\/]{1,}([\-])){7,}[\p{L&}0-9\.\'\/]{1,}$/) {
foreach $exp (1..$#-) {
$pos = $-[$exp];
$dash_pos = $word_start_pos + $pos;
$test_char = substr($text, $dash_pos, 1);
if ($test_char =~ /^[\-]$/) {
&load_changes('-', $dash_pos, 'Dash', ' ', 'Replace');
}
}
}