in reply to Re: First occurance in a string
in thread First occurance in a string
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: First occurance in a string
by toolic (Bishop) on Aug 29, 2008 at 17:10 UTC |