in reply to Regex in if statemetn

You're right, it shouldn't match an IP (unless you mean hostname?). Please provide some more sample input with comments on what should match and what shouldn't.

With the limited specs you've given, here's a regex: /^# ?(?:[A-Z]{2}|[a-z]{2})/ That'll match any two uppercase letters or any two lowercase letters, but not mixed ("Mo"). If you want mixed case to match too: /^# ?[A-Z]{2}/i If you want to match only two letters, not more, stick a \b at the end of the regex.