天行健, 君子以自强不息
Sunny's Blog
Title

各种需要的正则表达式

我不会正则,反复学了忘,忘了学,折腾,干脆直接记录下来。

1.Password: The password must be a minimum of 8 characters having at least 1 number, 1 lower, 1 upper, and 1 special character.

pattern='/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@$%^&+=])(?=\\S+$).{8,}$/'

pattern='/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@$%^&+=!\"'()*,-./:;<>?\\[\\\\\\]_`{|}~])(?=\\S+$).{8,}$/'

2.将string中的非数字去掉

string.replace(/[^0-9]/g, "")

3.测试string是否是纯数字

/^[0-9]*$/.test('8vb2511')

地势坤,君子以厚德载物