#!/usr/bin/perl # Differentes regexps @url = ("http://cyril.me:80/abc", "http://cyril.me/abc", "https://www.cyril.me/abc", "http://cyril.me", "https://wwwcyril.me/abc", "http://www.cyril.mercredi/"); # l'expression reguliere (attention aux echappements) $r = "^https?://([^/]+\\.)?cyril.me(:\\d+)?(/|\z)"; foreach my $u (@url) { if($u =~ /$r/i) { print "$u matches\n"; } else { print "$u not matches\n"; } }