davey10101 Posted March 4, 2010 Share Posted March 4, 2010 Hi, I'm trying to do a regex so that a string can only contain the following ABCDEIMSw4 and be 2 to 7characters long I've tried the following if(!preg_match("/^[ABCDEIMSw4]{2,7}$/",$data[5])){ echo "INVALID "; which fails if $data[5] is 'IC' can anyone help? cheers. Quote Link to comment Share on other sites More sharing options...
salathe Posted March 4, 2010 Share Posted March 4, 2010 Works fine for me: <?php $data[5] = 'IC'; if ( ! preg_match("/^[ABCDEIMSw4]{2,7}$/", $data[5])){ echo "INVALID "; } else { echo "VALID"; } ?> Quote Link to comment Share on other sites More sharing options...
davey10101 Posted March 4, 2010 Author Share Posted March 4, 2010 How odd!? I must have gremlins in my machine... Many Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.