in reply to Re^2: Multiple if statements matching part of one variable problem
in thread Multiple if statements matching part of one variable problem
Yes, that's completely incorrect.
First, "g" doesn't do that at all. It means (more or less) "all instances".
# Check for a match if (/pat/) { ... } # Find all matches while (/pat/g) { ... }
Second, that's not how regexps match at all.
print( 'abc' =~ /b/ ?1:0,"\n"); # 1 print( 'abc' =~ /^b\z/ ?1:0,"\n"); # 0 print( 'abc' =~ /^abc\z/ ?1:0,"\n"); # 1 print( 'a2b3c' =~ /(\d)/ ?$1:0,"\n"); # 2 print( 'a2b3c' =~ /^.*(\d)/ ?$1:0,"\n"); # 3 print( 'a2b3c' =~ /^.*?(\d)/ ?$1:0,"\n"); # 2
References:
|
|---|