finfan has asked for the wisdom of the Perl Monks concerning the following question:
I'm pulling my hair out, this seems so simple. I need to check the variable $index$an. I'm looking for any of these... # MO (any two caps letters with a # and space first) #MO (same thing with no space) # mo #mo
Here's what I'm using...
if (($input[$an] =~ /^# [a-z]/) || ($input[an] =~ /^#[A-Z]/)|| ($input[an] =~ /^#[a-z]/)|| ($input[an] =~ /^# [A-Z]/)) { ... }Problem is, even and IP address is matching as long as it has a # in front of it. Can't understand why this would match an ip.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex in if statement
by toolic (Bishop) on Mar 18, 2014 at 19:41 UTC | |
by finfan (Acolyte) on Mar 18, 2014 at 19:52 UTC | |
by 2teez (Vicar) on Mar 18, 2014 at 21:09 UTC | |
by kcott (Archbishop) on Mar 19, 2014 at 07:17 UTC | |
by hippo (Archbishop) on Mar 18, 2014 at 19:57 UTC | |
|
Re: Regex in if statemetn
by Anonymous Monk on Mar 18, 2014 at 20:07 UTC | |
|
Re: Regex in if statemetn
by frozenwithjoy (Priest) on Mar 19, 2014 at 12:42 UTC |