deep3101 has asked for the wisdom of the Perl Monks concerning the following question:
I wanted to know if there is any method to find the position of occurance of a particular character in a string, the character can ofcourse occur more than once.
$a="THE FOOD IS DELICIOUS";
Then if I want the position of "O" so I should get 6,7,19 or 5,6,18 will work too. But don't want to use arrays and conventional
$pos++;with for loop as the string is too big and lot of comparisons need to be done.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: finding the position of a particular character in a string
by NetWallah (Canon) on Oct 06, 2011 at 04:59 UTC | |
|
Re: finding the position of a particular character in a string
by keszler (Priest) on Oct 06, 2011 at 03:29 UTC | |
by BrowserUk (Patriarch) on Oct 06, 2011 at 04:45 UTC | |
|
Re: finding the position of a particular character in a string
by ww (Archbishop) on Oct 06, 2011 at 08:28 UTC | |
by deep3101 (Acolyte) on Oct 16, 2011 at 15:41 UTC | |
by Anonymous Monk on Oct 17, 2011 at 03:36 UTC | |
by deep3101 (Acolyte) on Nov 06, 2011 at 12:14 UTC | |
|
Re: finding the position of a particular character in a string
by Anonymous Monk on Oct 06, 2011 at 03:18 UTC |