|more useful options|
Is there an elegant way of resetting the match position?by pat_mc (Pilgrim)
|on Oct 22, 2009 at 15:23 UTC||Need Help??|
pat_mc has asked for the
wisdom of the Perl Monks concerning the following question:
I want to use a regex to extract ALL character n-tuplets from a given input string irrespective of case. To do so, I have written the following little script:
For $n = 2, the script provides the correct output:
I am wondering if there is a more elegant way to do this, e.g. by setting a suitable modifier on the regex. The manual adjustment of the match position after each regex match strikes me as cumbersome.
Any suggestions for improvement?
Thanks for your help in advance and best regards -