RE: regex puzzle



Oh, bug,it should be
<CODE>
use warnings;
use strict;

my @address = ("http://test";, "http://";, "www", "", "ftp:/foo" );

for (@address)
{
print "\"$_\" is valid. \n" if /^((http|ftp):\/\/)?.+$/;
}
</CODE>


|-----Original Message-----
|From: bingfeng zhao [mailto:zhao_bingfeng@xxxxxxxxxxxxx]
|Sent: Friday, July 29, 2005 1:48 PM
|To: Perl Beginners List
|Subject: regex puzzle
|
|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?
|
|

Attachment:smime.p7s
Description: S/MIME cryptographic signature



Relevant Pages