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 Quote Link to comment 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. 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.