如何告诉egrep不接受哪些字符
我想接受以 s 开头的字符串,而下一个字符(无论它是什么)必须在脚本中再包含两次(但不能少,不能多),并且在此字符不能是反斜杠之前。所以:
s(.)[now some chars except (.) and not ending with \]\1[some chars but not (.) and not ending with \]\1[some chars but not (.)]
\1 和 (.) 和 s 是正则表达式的真实部分
I want to accept string that begins with s than the next character (whatever it is) must be conatined in script two more times (but not less, not more) and before this char cannot be a backslash. So:
s(.)[now some chars except (.) and not ending with \]\1[some chars but not (.) and not ending with \]\1[some chars but not (.)]
\1 and (.) and s are real part of regex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 egrep 会削减它。
您需要一个可以执行前瞻断言的 grep,原因如下:
/^ s (.) (?:(?:\\.|(?!\1).)+\1){2} (?: \\.|(?!\1).)+ $/xs
I don't think egrep is going to cut it.
You need a grep that can do lookahead assertions, here's why:
/^ s (.) (?:(?:\\.|(?!\1).)+\1){2} (?:\\.|(?!\1).)+ $/xs