Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use JS regular expression Verification for Mobile phone number

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the mobile phone number how to use JS regular expression verification, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Concept

A regular expression is a logical formula for manipulating a string, that is, a "regular string" is formed by predefined specific characters and a combination of these specific characters. This "regular string" is used to express a filtering logic for a string.

Brief introduction

A regular expression is a logical formula for manipulating strings (including ordinary characters (for example, letters between an and z) and special characters (called "metacharacters"). It is to use predefined specific characters and a combination of these specific characters to form a "regular string", which is used to express a filtering logic for a string. A regular expression is a text pattern that describes one or more strings to match when searching for text.

The front-end regular expression verification is often the most numerous and the most complex, so I have sorted out some regular expressions that I have used recently, hoping to be helpful to everyone!

/ * legal uri * / export function validateURL (textval) {const urlregex = / ^ (?: http (s)?:\ /\ /)? [\ w. [\ w\. -] +) + [\ w\ -\. _ ~: /? # [\] @!\ $&'\ *\ + =.] + $/ return urlregex.test (textval)} / * lowercase * / export function validateLowerCase (str) {const reg = / ^ [Amurz] + $/ return reg.test (str)} / * uppercase * / export function validateUpperCase (str) {const reg = / ^ [Amurz] + $/ return reg.test (str)} / * uppercase and lowercase letters * / export function validateAlphabets (str) {const reg = / ^ [A-Za-z] + $/ return reg.test (str)} / * Market Price * / export function validatePrice (str) {const reg = / (^ [1-9]\ d * (\.\ d {1pr 2})? $) | (^ 0 (\.\ d {1pr 2})? $) / return reg.test (str)} / * inventory early warning value matches a non-negative integer (positive integer + 0) * / export function validatestockWarn (str) {const reg = / ^ (0 | [1) -9] [0-9] *) $/ return reg.test (str)} / * Price comparison website only verifies JD.com and SUNING website * / export function validateCompareWebsite (str) {const reg = / ^ ((https\:\ / [0-9a-zA-Z\ _] +\. | http\:\ /\ / [0-9a-zA-Z\ _] +\. | https\:\ /\ / | http\:\ /\ /) | ([0-9a -) ZA-Z\ _] +\.) {0Power1}) (jd | suning)\. (com$ | com\ / [\ S] *) / I return reg.test (str)} / * landline * / export function validateTelephone (str) {const reg = / ^ (\ d {3jue 4}\) |\ d {3Yu4}-|\ s)?\ d {7Yu14} $/ return reg.test (str)} / * Mobile phone number * / export function validatePhoneNumber (str) {const reg = / ^ [1] [3G4] 5,6,7,8 9] [0-9] {9} $/ return reg.test (str)} / * Mobile number and landline * / export function validatePhTelNumber (str) {const reg = / ^ ((0\ d {2 A-Za-z0 3} -\ d {7pr 8}) | (1 [3456789]\ d {9})) $/ return reg.test (str)} / * email address * / export function validateEmail (str) {const reg = / ^ [A-Za-z0-9\ u4e00- \ u9fa5] + @ [a-zA-Z0-9 cards -] + (\ .[ a-zA-Z0-9 cycles -] +) + $/ return reg.test (str)} / * ZIP code * / export function validateZipCode (str) {const reg = / ^ [1-9] [0-9] {5} $/ return reg.test (str)} / * ID card * / export function validateIDCard (str) {const reg = / (^\ d {15} $) | (^) \ d {18} $) | (^\ d {17} (\ d | X | x) $) / return reg.test (str)} / * Bank card number 15 or 16 digits or 19 digits * / export function validateBank (str) {const reg = / ^ ([1-9] {1}) (\ d {14} |\ d {18} |\ d {15}) $/ return reg.test (str)} / * taxpayer identification number * / export function validateTaxpayer (str) {const reg = / ^ ([1-9] {1}) (\ d {14} |\ d {18} |\ d {15}) $/ return reg.test (str)} / * match full spaces * / export function validateAllBlank (str) {const reg = / ^\ s+$/gi return reg.test (str)} Thank you for reading this article carefully I hope the article "how to use JS regular expression Verification for Mobile phone numbers" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report