Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在随机字母字符串中找到一个单词。例如,"pass"在以下字符串中查找
"pass"
asjh;ssdf2222fasdfpasslkjsdfk.^%£$fh
需要一些正则表达式帮助!
由于您确切地知道您在寻找什么,因此正则表达式是多余的。
if( str.indexOf("pass") > -1) { alert("Pass!"); }
只需尝试:
'asjh;ssdf2222fasdfpasslkjsdfk.^%£$fh'.match(/pass/);