prakash Posted July 3, 2007 Share Posted July 3, 2007 i need to validate data using regex. the dati will be of 12 numeric on starting and 5 letters at ending Here is what I made but think it is not correct. <?php $data=strtoupper($_POST['data']); $validData=preg_replace("/^[0-9]{12}+[A-Z]{5}$/",'',$data) ?> please let me correct Link to comment https://forums.phpfreaks.com/topic/58268-about-regex/ Share on other sites More sharing options...
effigy Posted July 3, 2007 Share Posted July 3, 2007 {12} is already quantifying [0-9], so you do not need the +. I would also replace $ with \z to prevent new lines from sneaking in. Link to comment https://forums.phpfreaks.com/topic/58268-about-regex/#findComment-288981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.