简体   繁体   中英

Javascript find a pattern in a string through regex

I have one string i want to check that wether that string has number or not , that string can contain the alphabets or mobile number with country code . So i want to detect that does it has mobile number ( which can have + or '0' and integers ) .

I tried using this [0-9] but i couldnt able to make the pattern for it .

thanks

Is this string coming from a form input? If so, there's a jQuery library for that called Masked Input .

If it's coming from a set variable that you want validated internally, you'll want to look here .

Hope this helps.

Got the solution

 \b[0-9+]+\b

Tested here

http://www.regular-expressions.info/javascriptexample.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM