Hi harangzsolt33,
As others have pointed out, the first argument to split is a regular expression. So to protect against special characters you could do something like split(quotemeta($PATTERN), $STRING, 2); (see quotemeta).
However, you don't need to parse URLs by hand, there's the URI module:
my @urls = ( "file:///c:/html/testing.html?P1=123&P2=%28%28BLAH+BLAH+BLAH%29%29 +", "http://www.cnn.org/g/ar.shtml?c=123055&s=%28Top+Stories+%29", "http://www.something.com/example/article.php?P1=123&P2=%28%28DATA ++GOES+HERE%29%29%0D%0A#PGTOP", ); use URI; for my $url (@urls) { my $u = URI->new($url); print "$u\n"; my @q = $u->query_form; print "\t\"$_\"\n" for @q; } __END__ file:///c:/html/testing.html?P1=123&P2=%28%28BLAH+BLAH+BLAH%29%29 "P1" "123" "P2" "((BLAH BLAH BLAH))" http://www.cnn.org/g/ar.shtml?c=123055&s=%28Top+Stories+%29 "c" "123055" "s" "(Top Stories )" http://www.something.com/example/article.php?P1=123&P2=%28%28DATA+GOES ++HERE%29%29%0D%0A#PGTOP "P1" "123" "P2" "((DATA GOES HERE)) "
Hope this helps,
-- Hauke D
In reply to Re: RegExp error PLEASE HELP!
by haukex
in thread RegExp error PLEASE HELP!
by harangzsolt33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |