js regular expression (E-mail, for example)

Regular test matches

//定义正则
var emailFormat=/^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/
//匹配正则
emailFormat.test('[email protected]')

Output: true

Regular extraction group, according to the extraction ()

//定义正则
var emailFormat=/^([a-zA-Z0-9]+)@[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/
//提取组
emailFormat.exec('[email protected]')

Output:

(2) ["[email protected]", "admin", index: 0, input: "[email protected]", groups: undefined]
Published 43 original articles · won praise 1 · views 3135

Guess you like

Origin blog.csdn.net/u011523953/article/details/104392709