regex - nested regexes in perl -


i looking write perl program looks following keywords in pattern:

`lint64 | strictlintflags64 | cflags64.` 

once ensure 1 of these patterns present in searched text, dig deeper see if there anomalies hidden in searched text. anomalies same words without string '64' appended in end. is:

lint | strictlintflags | cflags 

for example: pure string be:

"asd:   lint64_srcs" 

anomaly-ridden string be:

"cflags += $(ccverbose)lint:     lint64_prog" 

here test code wrote detect if particular search text has anomaly:

#!/usr/perl5/bin/perl -w  require 5.6.1; use strict; use warnings; use locale;  $string = "cflags += $(ccverbose)lint:     lint64_prog"; #my $string2 = "asd:   lint64_srcs";  if ($string =~ m/lint64|strictlintflags64|cflags64/ig) {     if ($string =~ m/lint(?!64)|strictlintflags(?!64)|cflags(?!64)/ig) {         print "anomaly-ridden"     }     else {         print "pure";     } } else {     print "garbage"; } 

this code detects $string2 correctly pure string.

unfortunately, $string detected "pure" instead of "anomaly-ridden".

any clues why ? also, if comment out outer-if loop, $string detected correctly "anomaly-ridden" string

get rid of /g flags; telling first match, try second match first match ended.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -