in reply to Re^2: Newbie Q:How do I compare items within a string?
in thread Newbie Q:How do I compare items within a string?
A tidier alternative to my pos() - length($1) is to consult @- .
The difference in indexing is that your code is matching on seperator characters instead of word characters. The end of your first match is the start of my second.push @{$positions{lc($1)}}, $-[1] while $string =~ /([A-Za-z']+)/g;
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Newbie Q:How do I compare items within a string?
by johngg (Canon) on May 09, 2006 at 10:23 UTC |