gongpex Posted October 3, 2019 Share Posted October 3, 2019 Hello everyone, I had used pregmatch to filter code calling with this code : if(preg_match('/^[61][0-9]*$/',$number)){ echo 'sorry you cannot use +61 to enter phone number use 123xxxx instead'; } it would filter if user giving number +61xxxxxx , but if they put number 2222222 it wouldn't filter and this is correct, the problem actually when user put number leading with 1 for example 12345678 it would filter or displaying echo. Q : How to filter so that when user put +61xxx only not 1xxxxx it would be run? Note : I provided input field so that user put their number only not with calling code. Thanks. Link to comment Share on other sites More sharing options...
Funce Posted October 3, 2019 Share Posted October 3, 2019 ^[61][0-9]*$ [61] matches either 6 OR 1 at the beginning. You may want to double check some of your regex. If you want to avoid having something start with +61 then you can just do this ^\+61 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now