in reply to Finding the positions of a character in a string
(From the CB where L~R was discussing this) Using index:
perl -le "my $str=qq(\n--\n--\n); my $p=0; do { $p=index($str,qq(\n),$ +p); print $p++; } while $p>0;"
And using s///.
perl -le "my $str=qq(\n--\n--\n); $str=~s/\n/print $-[0]; '\n'/ge;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding the positions of a character in a string
by sauoq (Abbot) on Nov 28, 2005 at 16:17 UTC | |
by demerphq (Chancellor) on Nov 28, 2005 at 16:22 UTC |