Dear monks
I'm trying to find the position of the match BEGINNING found with the following Regex, but I have really no idea how. The problem is that I'm searching in a span, so I really do not know how to come to the beginning position (I normally find it counting the length (characters) of the matching variables and "moving back" of that value starting from the pos($text) value).
my $text=<<EOF I'm trying to find the position of the match BEGINNING found with the +following Regex, but I have really no idea how. The problem is that I +'m searching in a span, so I really do not know how to come to the be +ginning position (I normally find it counting the length (characters) + of the matching variables and "moving back" of that value starting f +rom the pos($text) value). EOF my $UserInputPart1 = "to"; my $UserInputPart1 = "the"; while (($text=~ /$UserInputPart1\W+(?:\w+\W+){0,5}?$UserInputPart2/gi) + || ($text=~ /$UserInputPart2\W+(?:\w+\W+){0,5}?$UserInputPart1/gi)){ my $position = pos($text); print $position . "\n"; }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |