问题描述
有人有找到包含正则表达式的文件的代码吗?我假设你可以有两种不同的风格,一种用于BRE,一种用于EREs。
你会认为某种测试套件会有类似于isRegex()测试。任何人都可以有任何代码?
我看到这是讨论,但没有看到任何实际的回应。如果我想grep for任何包含正则表达式的文件,或许以典型的//为界限,我该怎么做?
正则表达式本身不是。线索是它们包含括号和方括号,并且必须是平衡的。
正则表达式本身可以用,并使用进行分析。
Does anyone have code for finding a file that contains a regular expression? I would assume you could have two different flavors, one for BREs and one for EREs.
You would think some kind of test suites would have something like an isRegex() test. Can anyone have any code? Looking for something comprehensive of course.
I see this was discussed here but didn't see any practical responses. If I want to grep for any file that contains a regular expression, perhaps bounded by the typical //, how would I do it?
Regular expressions are themselves not a regular language. The clue is that they contain parentheses and square brackets and such that must be balanced.
A regular expression itself can be described by a context-free grammar, and parsed with a recursive-descent parser.
这篇关于寻找正则表达式的正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!