Skip to content
Advertisement

php regex number and + sign only

I need a php function to validate a string so it only can contains number and plus (+) sign at the front.

Example:

+632444747 will return true
632444747 will return true
632444747+ will return false
&632444747 will return false

How to achieve this using regex?

Thanks.

Advertisement

Answer

Something like this

JavaScript

Testing it

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement