Created
December 9, 2011 23:53
-
-
Save amiri/1453889 to your computer and use it in GitHub Desktop.
Possible regex mistake?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $original = "belize-i-27869844"; | |
(my $original_regexed = $original) =~ s/^(.*)?-(\d+|i-[0-9a-f]{8})\b(.*)/$1-$3/; | |
print STDERR "My original regex turns $original into $original_regexed\n"; | |
my $text = "belize-i-27869844"; | |
( my $new_text = $text ) =~ s/^(.+?)-(\d+|i-[0-9a-f]{8})\b(.*)/$1-$3/; | |
print STDERR "My changed regex turns $text into is $new_text\n"; | |
my $more = 'belize-01'; | |
( my $new_more = $more ) =~ s/^(.+?)-(\d+|i-[0-9a-f]{8})\b(.*)/$1-$3/; | |
print STDERR "My new regex turns $more into $new_more\n"; | |
my $even_more = 'belize-i-27869844.campusexplorer.com'; | |
( my $again = $even_more ) =~ s/^(.+?)-(\d+|i-[0-9a-f]{8})\b(.*)/$1-$3/; | |
print STDERR "My new regex turns $even_more into $again\n"; | |
my $still = 'belize-39.campusexplorer.com'; | |
( my $still_again = $still ) =~ s/^(.+?)-(\d+|i-[0-9a-f]{8})\b(.*)/$1-$3/; | |
print STDERR "My new regex turns $still into $still_again\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment