heidi has asked for the wisdom of the Perl Monks concerning the following question:
Now what i want to do is, 1) I want to split the string during the second occurance of K or R. and not during his first occurence. In that case, in my array, each fragment will contain two K (or) R, one being somewhere in the string and other will be at the end of string ending with a K or R. 2) Likewise, i also want to split the string during the third occurance of K or R and not during the second occurance. In that case, my array will have fragments containing three K's or R's, two being somewhere in the string and the last one will be at the end of string ending with a K or R. Please help me learn :) Regards Heidi.I have a string like $str="AJKDHAKAESRADADKLASRRASDASDKASEKA" for this i have regex @ar=split('(?<=[KR](?!P))',$str); #to split where i ever i see a K or +R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: want regex to find 2nd and 3rd occurence of a character
by toolic (Bishop) on May 22, 2008 at 19:15 UTC | |
by heidi (Sexton) on May 22, 2008 at 19:34 UTC | |
|
Re: want regex to find 2nd and 3rd occurence of a character
by CountZero (Bishop) on May 22, 2008 at 19:29 UTC | |
by heidi (Sexton) on May 22, 2008 at 19:39 UTC | |
|
Re: want regex to find 2nd and 3rd occurence of a character
by moritz (Cardinal) on May 22, 2008 at 18:54 UTC | |
|
Re: want regex to find 2nd and 3rd occurence of a character
by psini (Deacon) on May 22, 2008 at 19:29 UTC | |
|
Re: want regex to find 2nd and 3rd occurence of a character
by DrHyde (Prior) on May 23, 2008 at 10:03 UTC |