perl -wMstrict -le "my $string = 'foo/bar/pattern/baz/pattern/quux'; my $pattern = qr{ pat{2}ern }xms; if ($string =~ m{ ($pattern) }xms) { print qq(start: $-[1]); } else { print 'pattern not found'; } my $idx = index $string , 'pattern'; print qq(index: $idx); " start: 8 index: 8
Update:
As per the documentation, a hyphen renders as a space in [doc://name#anchor] links. How can I get a hyphen to render as a hyphen? (Thanks toolic — @- looks like @- now.)
In reply to Re^2: First occurance in a string
by AnomalousMonk
in thread First occurance in a string
by anand_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |