Hi
I am trying to locate all strings seperated by the string -CR-, the string will have an unknown number of these -CR- strings, I've used the regex:
^(?:(.*?)-CR-)+$
As shown in the test code:
my ($myString)="This is the first line-CR-second line-CR-third line-CR-fourth line-CR-fifth line-CR-";
if ($myString =~ /^(?:(.*?)-CR-)+$/)
{
print "String1 $1 String2 $2 String3 $3 String4 $4 String5 $5\n";
}
However I only ever get the last line "fifth line" which goes to $1, it would seem that only $1 is ever set, and keeps getting overwritten. for example if I replace:
if ($myString =~ /^(?:(.*?)-CR-)+$/)
with:
if ($myString =~ /^(?:(.*?)-CR-){7,}$/)
As I expected I get no output as there only five repeats possible. If I change the 7 to number 5 or less than I again get the same last line found in $1, anyone got any ideas?
Thanks
Jon