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
In reply to Re: string matching
by Your Mother
in thread string matching
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |