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. Link to comment https://forums.phpfreaks.com/topic/194149-specific-characters/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/194149-specific-characters/#findComment-1021515 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 Link to comment https://forums.phpfreaks.com/topic/194149-specific-characters/#findComment-1021522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.