mmartin has asked for the wisdom of the Perl Monks concerning the following question:
fakesite.com/fake-url/fake_picture.jpg http://www.google-analytics.com/collect http://www.fakesite.com/files-png/10453229-7.png http://assets.pinterest.com/js/pinit.js http://assets.pinterest.com/js/pinit_main.js http://www.fakesite.com/files-png/10455009-1.png http://tacoda.at.atwola.com/atx/sync/addthis/addt/default? http://epiv.cardlytics.com/c/?pr=11018&prc=550 fakesite.com/images/fake_picture.jpg http://www.rating-system.com/webservice/RatingService.svc/GetReviews http://www.fakesite.com/files-png/1045997098.png http://safebrowsing-cache.google.com/safebrowsing/rd/ChFnb29nLXBo http://dnn506yrbagrg.cloudfront.net/pages/scripts/022/131.js?39616
#!/usr/bin/perl use strict; use warnings; my $input_file = "/home/User/Documents/fakeDir/test_urls.txt"; my @RESULTS; open(INPUT, "< $input_file") or die "Error: There was an error opening + the input file: $!\n\n"; my $x = 0; while (<INPUT>) { my $line = "$_"; chomp($line); ### INCLUDE STATEMENT: if ($line =~ /^(http:\/\/)?(www\.)?fakesite.com.*/g) { print "CHECKING --> '$line'\n"; ### EXCLUDE STATEMENT: # *Original Regex went here instead: # --> if ($line !~ /$ORINGAL-REGEX/g) if ($line =~ /files-png/g) { print "\t\tFOUND IT....\n\n"; $RESULTS[$x] = "$line"; $x++; } else { print "\t\tNOT FOUND....\n\n"; } } } close INPUT;
CHECKING --> 'fakesite.com/fake-url/fake_picture.jpg' NOT FOUND.... CHECKING --> 'http://www.fakesite.com/files-png/10453229-7.png' NOT FOUND.... CHECKING --> 'http://www.fakesite.com/files-png/10455009-1.png' NOT FOUND.... CHECKING --> 'fakesite.com/images/fake_picture.jpg' NOT FOUND.... CHECKING --> 'http://www.fakesite.com/files-png/1045997098.png' NOT FOUND....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why this Simple REGEX does Not Match?
by choroba (Cardinal) on Mar 12, 2015 at 22:39 UTC | |
|
Re: Why this Simple REGEX does Not Match?
by roboticus (Chancellor) on Mar 12, 2015 at 22:42 UTC | |
|
Re: Why this Simple REGEX does Not Match?
by gpapkala (Acolyte) on Mar 12, 2015 at 22:38 UTC | |
|
Re: Why this Simple REGEX does Not Match? (re debug match globally pos)
by Anonymous Monk on Mar 12, 2015 at 22:53 UTC | |
|
Re: Why this Simple REGEX does Not Match?
by mmartin (Monk) on Mar 13, 2015 at 16:16 UTC | |
|
Re: Why this Simple REGEX does Not Match?
by mmartin (Monk) on Mar 13, 2015 at 20:54 UTC |