We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
正则表达式对于每个开发者都非常重要,用的好能在一些关键时刻让自己变得轻松。推荐个正则可视化工具:regulex,帮助学习者直观验证。
如果匹配成功,exec() 方法返回一个数组;匹配失败,返回 null
let regexExec = /#(.*)$/.exec('http://localhost:8081/#/demo') /* [ '#/demo', '/demo', index: 22, input: 'http://localhost:8081/#/demo' ] */
查看正则表达式与指定的字符串是否匹配。返回 true 或 false
let regexTest = /#(.*)$/.test('http://localhost:8081/#/demo') // true
类似regex.exec(string)
let stringMatch = 'http://localhost:8081/#/demo'.match(/#(.*)$/) // [ '#/demo', // '/demo', // index: 22, // input: 'http://localhost:8081/#/demo' ]
匹配成功,search() 返回正则表达式在字符串中首次匹配项的索引。否则,返回 -1。类似regex.test()
let stringSearch = 'http://localhost:8081/#/demo'.search(/#(.*)$/) // 22
其他正则相关语法@jawil总结的十分详细,故转载在此:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
正则表达式对于每个开发者都非常重要,用的好能在一些关键时刻让自己变得轻松。推荐个正则可视化工具:regulex,帮助学习者直观验证。
正则方法
regex.exec(string)
如果匹配成功,exec() 方法返回一个数组;匹配失败,返回 null
regex.test(string)
查看正则表达式与指定的字符串是否匹配。返回 true 或 false
string.match(regex)
类似regex.exec(string)
string.search(regex)
匹配成功,search() 返回正则表达式在字符串中首次匹配项的索引。否则,返回 -1。类似regex.test()
其他正则相关语法@jawil总结的十分详细,故转载在此:
The text was updated successfully, but these errors were encountered: