M
Martijn Houtman
Hello,
I have an issue parsing a string with a regular exression. Here's a small
example:
@foobar = ("foobarbarbarfoo" =~ m/(foo)(bar)*(foo)/g);
this makes the array foobar contain:
{"foo", "bar", "foo"}
while I want it to be
{"foo", "bar", "bar", "bar", "foo"}
The *-operator seems to 'forget' the first few elements and just returns the
last element, which is stored in the $2 variable. Is there a way to make it
return the full list of elements?
I have been suggested to split the string into three pieces first, and then
parse them separately, but I'd still like to do it with a single regular
expression.
Thanks in advance!
Regards,
I have an issue parsing a string with a regular exression. Here's a small
example:
@foobar = ("foobarbarbarfoo" =~ m/(foo)(bar)*(foo)/g);
this makes the array foobar contain:
{"foo", "bar", "foo"}
while I want it to be
{"foo", "bar", "bar", "bar", "foo"}
The *-operator seems to 'forget' the first few elements and just returns the
last element, which is stored in the $2 variable. Is there a way to make it
return the full list of elements?
I have been suggested to split the string into three pieces first, and then
parse them separately, but I'd still like to do it with a single regular
expression.
Thanks in advance!
Regards,