我真的不知道正则表达式,所以有人可以举例说明如何修复这个正则表达式http://rubular.com/r/UdzYMJc9iE :
/\b([stack over flow]+)+\b/不匹配空格并且只匹配精确的单词(堆栈匹配ac作为单词,我想只匹配堆栈),tia。
我希望当我们'norem etiam nam'只匹配正则表达式中的这三个单词时,没有空格。
我尝试使用\ s,\ S,/ x,但没有结果..
I'm don't know regex really well, so can someone give me example how to fix this regex http://rubular.com/r/UdzYMJc9iE:
/\b([stack over flow]+)+\b/not to match whitespaces and to match only exact words (stack matches ac as word, I want to match only stack), tia.
I want when we have 'lorem etiam nam' to match only these exact 3 words from the regex, without spaces.
I tried using \s, \S, /x, but there was no result..
最满意答案
如果您只想匹配三个选项,请使用| 语法,并将它们分组为普通括号:
/\b(stack|over|flow)+\b/不确定+或您想要匹配的内容。
If you only want to match three alternatives, use the | syntax, and group them into normal parenthesis:
/\b(stack|over|flow)+\b/Not sure about the + or what exactly you wanted to match.
更多推荐
发布评论