in reply to Re^3: How can one create an array of the indices at which a given character appears in a string? (updated)
in thread How can one create an array of the indices at which a given character appears in a string?
my $input = 'rnbqkbnr'; my @results; push @results, $-[0] while $input =~ /(n)/g; print "@results";
Update: Capturing parens not needed:
push @results, $-[0] while $input =~ /n/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How can one create an array of the indices at which a given character appears in a string?
by LanX (Saint) on Jan 29, 2015 at 14:50 UTC | |
|
Re^5: How can one create an array of the indices at which a given character appears in a string?
by DanBev (Scribe) on Jan 29, 2015 at 14:54 UTC |