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

What are the Web front-end regular tool functions

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what are the Web front regular tool functions". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the Web front regular tool functions".

Verify the stock symbol (A shares)

/ * * @ param {string} value * / export const isAShare = value = > / ^ (s [hz] | S [HZ]) (000 [\ d] {3} | 002 [\ d] {3} | 300 [\ d] {3} | 600 [\ d] {3} | 60 [\ d] {4}) $/ g.test (value)

Verify the video link address (video format can be added or deleted as needed)

/ * * @ param {string} value * / export const isVideoUrl = value = > / ^ https?:\ /\ / (. +\ /) + (\. (swf | avi | flv | mpg | mov | wav | asf | 3gp | mkv | rmvb | mp4)) $/ i.test (value)

Verify the link address of the picture (the picture format can be added or deleted as needed)

/ * * @ param {string} value * / export const isImageUrl = value = > / ^ https?:\ /\ / (. +\ /) + (. (gif | png | jpg | jpeg | webp | svg | psd | bmp | tif)) $/ i.test (value)

Verify Chinese names

/ * * @ param {string} value * / export const isChineseName = value = > / ^ (?: [\\ u4e00 -\ u9fa5] {2jue 16}) $/ g.test (value)

Verify English names

/ * * @ param {string} value * / export const isEnglishName = value = > / (^ [a-zA-Z] {1} [a-zA-Z\ s] {0 20} [a-zA-Z] {1} $) / g.test (value)

Verify the license plate number (new energy)

/ * * @ param {string} value * / export const isLicensePlateNumberNER = value = > / [Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yunnan, Liao Black, Shandong, New Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Ganjin, Shaanxi, Fujian, Guizhou, Guangdong, Qinghai, Tibet, Sichuan and Ningqiong] {1} [A-HJ-NP-Z] {1} (([0-9] {5} [DF]) | ([DF] [A-HJ-NP-Z0-9] [0-9] {4})) $/ g.test (value)

Verify the license plate number (non-new energy)

/ * * @ param {string} value * / export const isLicensePlateNumberNNER = value = > / ^ [Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yunnan, Liao Black, Shandong, New Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Gan Jin, Shaanxi, Fujian, Gui, Guangdong, Qinghai, Tibet, Sichuan Ningqiong [1} [A-HJ-NP-Z] {1} [A-Z0-9] {4} [A-Z0-9 student police Hong Kong and Macao] {1} $/ g.test (value)

Verify the license plate number (new energy + non-new energy)

/ * * @ param {string} value * / export const isLicensePlateNumber = value = > / ^ (?): [Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yunnan, Liao Hei, Hunan, Anhui, New Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Gansu, Shanxi, Shaanxi, Fujian, Gui, Guangdong, Qinghai, Tibet, Sichuan Ningqiong [1} [A-HJ-NP-Z] {1} (?: [0-9] {5} [DF]) | (: [DF] (?: [A-HJ-NP-Z0-9]) [ 0-9] {4})) | (?): [Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yun, Liao Hei, Hunan, Anhui, New Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Gansu, Shanxi, Shaanxi, Fujian, Guizhou, Guangdong, Qinghai, Tibet, Sichuan and Ningqiong] {1} [A-HJ-NP-Z0 Z] {1} [A-HJ-NP-Z0-9] {4} [A-HJ-NP-Z0-9 student police officers in Hong Kong and Macao] {1}) $/ g.test (value)

Verify the mobile phone number in China (rigorous), according to the latest mobile phone number released by the Ministry of Industry and Information Technology in 2019.

/ * @ param {string} value * / export const isMPStrict = value = > / ^ (?: (?:\ + | 00) 86)? 1 (?: 3 [\ d]) | (?: 4 [5-7 | 9]) | (?: 6 [5-7]) | (?: 7 [0-8]) | (?: 8 [\ d]) | (?: 9 [1 | 8 | 9])\ d {8} $/ g.test (value)

Verify email (mailbox)

/ * @ param {string} value * / export const isEmail = value = > / ^ [a-zA-Z0-9.3 percent recovery% purchase]? ^ _ `{|} ~ -] + @ [a-zA-Z0-9] (?: [a-zA-Z0-9 -] {0jue 61} [a-zA-Z0-9])? (?:\. [a-zA-Z0-9] (?: [a-zA-Z0-9 -] {0pm-61}) [a-zA-Z0-9])?) * $/ g.test (value)

Verify ID card number (1st generation, 15 digits)

/ * * @ param {string} value * / export const isIDCardOld = value = > / ^\ d {8} (0\ d | 10 | 11 | 12) ([0-2]\ d | 30 | 31)\ d {3} $/ g.test (value)

Verify the ID card number (generation 2, 18 digits). The last digit is the check bit, which may be a number or the character X

/ * * @ param {string} value * / export const isIDCardNew = value = > / ^\ d {6} (18 | 19 | 20)\ d {2} (0\ d | 10 | 11 | 12) ([0-2]\ d | 30 | 31)\ d {3} [\ dXx] $/ g.test (value)

Verify passport (including Hong Kong and Macao)

/ * * @ param {string} value * / export const isPassport = value = > / (^ [EeKkGgDdSsPpHh]\ d {8} $) | ([Ee] [a-fA-F])) | ([DdSsPp] [Ee]) | ([Kk] [Jj]) | ([Mm] [Aa]) | (1 [45]))\ d {7} $) / g.test (value)

Verify that the account is legal (begins with a letter, allows 5-16 bytes, and allows alphanumeric underscore combinations

/ * * @ param {string} value * / export const isWebAccount = value = > / ^ [a-zA-Z]\ w {4 {15} $/ g.test (value)

Verify Chinese / Chinese characters

/ * * @ param {string} value * / export const isChineseCharacter = value = > / ^ (?: [\\ u3400 -\\ u4DB5\\ u4E00 -\\ u9FEA\\ uFA0E\\ uFA11\\ uFA13\\ uFA14\\ uFA1F\ uFA21\\ uFA23\\ uFA27-\ uFA29] | [\ uD840-\\ uD868\\ uD86A-\ uD86C\\ uD86F-\ uD872\\ uD874-\ uD879] [\\ uDC00-\\ uDFFF] | [\\ uDC00-\ uDED6\\ uDF00-\\ uDFFF] |\ uD86D [\\ uDC00-\\ uDF34\\ uDF40-\\ uDFFF] |\\ uDC00-\\ uDC1D\\ uDC20-\\ uDFFF] |\\ uDC00-\\ uDEA1\\ uDEB0-\\ uDFFF] |\ uD87A [\\ uDC00-\ uDFE0]) + $/ g.test (value)

Validate decimal

/ * * @ param {string} value * / export const isDecimal = value = > / ^\ d +\.\ d+$/g.test (value)

Verify the number

/ * param {string} value * / export const isNumber = value = > / ^\ d {1,} $/ g.test (value)

Verify the QQ number format

/ * * @ param {string} value * /

Verify the English alphabet

/ * * @ param {string} value * / export const isEnglish = value = > / ^ [a-zA-Z] + $/ g.test (value)

Verify uppercase letters

/ * * @ param {string} value * / export const isCapital = value = > / ^ [Amurz] + $/ g.test (value)

Verify lowercase letters

/ * * @ param {string} value * / export const isLowercase = value = > / ^ [Amurz] + $/ g.test (value)

Validation cannot contain letters

/ * * @ param {string} value * / export const isNoWord = value = > / ^ [^ A-Za-z] * $/ g.test (value)

Verify Chinese and numbers

/ * * @ param {string} value * / export const isCHNAndEN = value = > / ^ (: [\\ u3400 -\\ u4DB5\\ u4E00 -\\ u9FEA\\ uFA0E\ uFA0F\\ uFA11\\ uFA14\\ uFA1F\ uFA21\\ uFA23\\ uFA27-\ uFA29] | [\ uD840-\\ uD868\\ uD86A-\\ uD86C\\ uD86F-\ uD872\\ uD874-\ uD879] |\\ uDC00-\\ uDFFF] | UD869 [\\ uDC00-\ uDED6\\ uDF00-\ uDFFF] |\ uD86D [\\ uDC00-\\ uDF34\\ uDF40-\\ uDFFF] |\\ uDC00-\\ uDC1D\\ uDC20-\\ uDFFF] |\ uD873 [\\ uDC00-\\ uDEA1\\ uDEB0-\\ uDFFF] |\ uD87A [\\ uDC00-\\ uDFE0]) | (\ d) + $/ g.test (value)

Verify Postal Code (China)

/ * * @ param {string} value * / export const isPostcode = value = > / ^ (0 [1-7] | 1 [0-356] | 2 [0-7] | 3 [0-6] | 4 [0-7] | 5 [1-7] | 6 [1-7] | 7 [0-5] | 8 [013-6])\ d {4} $/ g.test (value)

Verify WeChat account, 6 to 20 digits, starting with letters, letters, numbers, minus signs, underscores

/ * * @ param {string} value * / export const isWeChatNum = value = > / ^ [a-zA-Z] [- _ a-zA-Z0-9] {5pm 19} $/ g.test (value)

Verify hexadecimal color

/ * * @ param {string} value * / export const isColor16 = value = > / ^ #? ([a-fA-F0-9] {6} | [a-fA-F0-9] {3}) $/ g.test (value)

Verify the train number

/ * * @ param {string} value * / export const isTrainNum = value = > / ^ [GCDZTSPKXLY1-9]\ d {1mer4} $/ g.test (value)

Verify the phone body code (IMEI)

/ * * @ param {string} value * / export const isIMEI = value = > / ^\ d {15pm 17} $/ g.test (value)

Verify magnetic links (loose match)

/ * * @ param {string} value * / export const isMagnet = value = > / ^ magnet:\? xt=urn:btih: [0-9a-fA-F] {40,}. $/ g.test (value)

Verify email (mailbox)

/ * * @ param {string} value * / export const isWindowsFolderPath = value = > / ^ [a-zA-Z]:\\ (?:\ w+\\?) * $/ g.test (value); copy the code

Verify that the version number format must be X.Y.Z

/ * * @ param {string} value * / export const isVersion = value = > / ^\ d + (?:\.\ d +) {2} $/ g.test (value)

Verify the bank card number (10 to 30 digits, covering public / private accounts, refer to WeChat Pay)

/ * * @ param {string} value * / export const isAccountNumber = value = > / ^ [1-9]\ d {9pm 29} $/ g.test (value)

Verify the unified social credit code

/ * * @ param {string} value * / export const isCreditCode = value = > / ^ [0-9A-HJ-NPQRTUWXY] {2}\ d {6} [0-9A-HJ-NPQRTUWXY] {10} $/ g.test (value)

Verify Thunderbolt link

/ * * @ param {string} value * / export const isThunderLink = value = > / ^ thunderx?:\ /\ / [a-zA-Z\ d] + = $/ g.test (value) Thank you for your reading, these are the contents of "what are the Web front-end regular tool functions". After the study of this article, I believe you have a deeper understanding of what the Web front-end regular tool functions have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Development

Wechat

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

12
Report