in reply to string matching
Use URI. URIs are more complicated than they seem and this makes handling them easier. Here's an example with a couple of surprise cases that show why/how a regular expression can be much more difficult.
use strict; use warnings; use URI; URI: for my $raw ( <DATA> ) { my $uri = URI->new($raw); if ( $uri->scheme ne "https" ) { warn "$uri is not secure, skipping\n"; next URI; } if ( $uri->path =~ m,/\z, ) { warn "$uri has a trailing slash, skipping\n"; next URI; } print "GOOD: $uri\n"; } __DATA__ http://perlmonks.org/?node_id=825405 https://gmail.com https://gmail.com/ https://perlmonks.org/? https://mail.google.com/mail/#inbox
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string matching
by ungalnanban (Pilgrim) on Feb 27, 2010 at 09:53 UTC | |
by Your Mother (Archbishop) on Feb 27, 2010 at 20:25 UTC |