Do it with URI and URI::QueryParam and you'll have code that works much more reliably and is easier to read and extend. Here's a snippet to get you going-

use URI; use URI::QueryParam; while ( <DATA> ) { chomp; my $uri = URI->new($_); next unless $uri->scheme eq 'http'; next unless $uri->query_param; print $uri, $/; for my $param ( $uri->query_param ) { printf(" %s --> %s\n", $param, join(", ", $uri->query_param($param)) ); } } __DATA__ http://google.com/?var1=aaaa&var2=aa https://google.com/?var1=aaaa&var2=aa http://google.com/ ftp://google.com/ mailto:moo@gmail.com http://google.com/?var=one&var=two&var=three

In reply to Re: url get variables regex by Your Mother
in thread url get variables regex by clone4

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.