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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.