I'm using this code to split:
[HIGHLIGHT="Perl"]# Split the lines by *
@code = split(/*/, $my_lines);[/HIGHLIGHT]
but I get this error:
"Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at c:\projects\line_split.pl line 31"
Any ideas how to fix this or why this error is generated? I can split with:
[HIGHLIGHT="Perl"]# Split the lines by *
@code = split(/'/, $my_lines);[/HIGHLIGHT]
and everything works fine.
'*' is a quantifier, it means: zero or more when used in a regular expression, which is what split(//) is. If you want to split on a literal * you have to escape it:
@code = split(/\*/, $my_lines);
or use single-quotes:
@code = split('*', $my_lines);
That works! Thanks
I didn't think about it being a quantifier.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks