I'm trying to come up with a regular expression that matches 2-character country codes. Currently, I have it so that it works for any 2 characters. However, I don't want it to match when the country code provided is "US". Can someone help me figure out what I need to change? $regex = '/^([a-z]{2})$/i'; Code (markup):
Cant you use: $countryCode = "UK"; if(strtolower($countryCode) != "us"){ //Do Stuff } PHP: That will make the country code lowercase (so it matches any case), and if it doesn't equal "us", then it can do stuff. EDIT: Assumed you were using PHP, but any language should be more or less do that - take a string to lowercase, and compare it with a "does not equal" operator.
My goal is to create a regex that can be data-specific so that I don't have to make the code data-specific. As such, creating an if-condition isn't an option for me.