Part of the regular judgment of user input information

In order to avoid the user's random input and pass the verification, we often use regular expressions to verify whether the information entered by the user conforms to the specification. The content of this part is basically collected on the Internet. I will share it with you here. If you need it, you can record it in your own Youdao cloud.

How to verify?

Of course, there are many ways to verify, and it is recommended to use the test() method to verify.

let isTrue=RegExpObject.test(string);// RegExpObject为正则 string是要检测的字符串
// 如果字符串 string 中含有与 RegExpObject 匹配的文本,则返回 true,否则返回 false。
if (isTrue){
    //验证成功 do something
}elseP{
    //验证失败

} 原文:http://obkoro1.com/2018/05/05/%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E7%94%A8%E6%88%B7%E6%B5%8F%E8%A7%88%E5%99%A8%E4%BB%A5%E5%8F%8A%E4%B8%80%E4%BA%9B%E5%89%8D%E7%AB%AF%E5%B8%B8%E7%94%A8%E7%9A%84%E6%AD%A3%E5%88%99%E8%A1%A8%E5%8D%95%E9%AA%8C%E8%AF%81/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326614414&siteId=291194637