| Flemming Greve Skovengaard 2005-07-29, 5:01 pm |
| bingfeng zhao wrote:
> See following sample code:
>
> <CODE>
> use warnings;
> use strict;
>
> my @address = ("http://test", "http://", "www", "", "ftp:/foo" );
>
> for (@address)
> {
> print "\"$_\" passed! \n" if /^((http|ftp):\/\/)?.+$/;
> }
> </CODE>
>
> the running result is:
> "http://test" is valid.
> "http://" is valid.
> "www" is valid.
> "ftp:/foo" is valid.
>
> why "http://" and "ftp:/foo" can pass the check?
>
Because ((http|ftp):\/\/) is optional ( the ? following it does that ),
so any line with anything between the start and end of the line will pass.
--
Flemming Greve Skovengaard FAITH, n.
a.k.a Greven, TuxPower Belief without evidence in what is told
<dsl58893@vip.cybercity.dk> by one who speaks without knowledge,
4112.38 BogoMIPS of things without parallel.
|