On Mar 14, 2007, at 4:09 AM, Mario Minati wrote:
So this brings me back to my problem to find a constrain that
handles the http
webadresses a user could type. For me that should include the
fragment and
doesn't need necessarily the https? scheme.
For now I would suggest to make a custom Constraint out of it which
doesn't
need to be part of the main formfu distribution.
The easiest way to do that would be to build a custom Regexp::Common
subclass using the pieces that Regexp::Common::URI already provides...
package Regexp::Common::WebAddress;
use strict;
local $^W = 1;
use Regexp::Common qw( pattern clean no_defaults );
use Regexp::Common::URI::RFC2396 qw(
$host $port $path_segments $query $fragment
);
pattern name => [ qw( WebAddress ) ],
create => "(?k:(?k:https?)://(?k:$host)(?::(?k:$port))?".
"(?k:/(?k:(?k:$path_segments)(?:[?](?k:
$query))?))?".
"(?k:#$fragment)?)";
#!/usr/bin/perl -w
use Regexp::Common qw( WebAddress );
print "$_: ".( /^$RE{WebAddress}$/ ? "VALID" : "NOT VALID" )."\n" for (
'http://www.google.com/',
'foo://blah.arghh!/',
'foo://foo.bar/',
'https://minati.de./',
'http://minati.de./',
'https://minati.de/index.html#lkj',
'http://minati.de/index.html#lkj',
);
--
Jason Kohles
[EMAIL PROTECTED]
http://www.jasonkohles.com/
"A witty saying proves nothing." -- Voltaire
_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget