Skip to content
New issue

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

正则表达式 #52

Open
zhouzhongyuan opened this issue Apr 28, 2017 · 1 comment
Open

正则表达式 #52

zhouzhongyuan opened this issue Apr 28, 2017 · 1 comment

Comments

@zhouzhongyuan
Copy link
Owner

zhouzhongyuan commented Apr 28, 2017

@zhouzhongyuan
Copy link
Owner Author

^Home(?:\/(?=$))?$

解释:
(?:x)

匹配 'x' 但是不记住匹配项。这种叫作非捕获括号,使得你能够定义为与正则表达式运算符一起使用的子表达式。来看示例表达式 /(?:foo){1,2}/。如果表达式是 /foo{1,2}/,{1,2}将只对 ‘foo’ 的最后一个字符 ’o‘ 生效。如果使用非捕获括号,则{1,2}会匹配整个 ‘foo’ 单词。

x(?=y)

匹配'x'仅仅当'x'后面跟着'y'.这种叫做正向肯定查找。
例如,/Jack(?=Sprat)/会匹配到'Jack'仅仅当它后面跟着'Sprat'。/Jack(?=Sprat|Frost)/匹配‘Jack’仅仅当它后面跟着'Sprat'或者是‘Frost’。但是‘Sprat’和‘Frost’都不是匹配结果的一部分。

来源react-navigation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant