比较正则表达式 [英] Compare regular expressions
问题描述
我正在编写一个带有大数据流的程序,模块可以使用正则表达式连接到
。
现在我''我希望每次得到一条线都不需要测试所有的表情,
大部分时间,其中一个有匹配意味着没有其他人
可以有这样的。
但是在源代码中也有正则表达式可以
包含的情况。另一个表达式,如:
" ^ strange line(\w +)和(\w +)$"和^奇怪的行(\w +)(?:。*?)$"在
这种情况下我想首先测试秒数,并且只有在数学测试的时候才能测试。/ /
秒。
有人知道这样的测试是否可行?
如果exp0.contains(exp1):...
Hi, I''m writing a program with a large data stream to which modules can
connect using regular expressions.
Now I''d like to not have to test all expressions every time I get a line,
as most of the time, one of them having a match means none of the others
can have so.
But ofcource there are also cases where a regular expression can
"contain" another expression, like in:
"^strange line (\w+) and (\w+)$" and "^strange line (\w+) (?:.*?)$" in
which case I''d like to first test the seccond and only if it mathces test
the seccond.
Do anybody know if such a test is possible?
if exp0.contains(exp1): ...
推荐答案
"和^ strange line(\w +)(?:。*?)
" and "^strange line (\w+) (?:.*?)
"在
这种情况下我想首先测试秒数,并且只有在数学测试的时候才能测试。/ /
秒。
有人知道这样的测试是否可行?
如果exp0.contains(exp1):...
" in
which case I''d like to first test the seccond and only if it mathces test
the seccond.
Do anybody know if such a test is possible?
if exp0.contains(exp1): ...
Thomas Dybdahl Ahle schrieb:
Thomas Dybdahl Ahle schrieb:
我正在编写一个包含大数据流的程序,模块可以使用正则表达式连接
。
现在我不想在每次收到行时都测试所有表达式,
大部分时间,其中一个匹配意味着没有其他人
可以这样。
但是在源代码中也存在正则表达式可以
包含的情况。另一个表达式,如:
" ^ strange line(\w +)和(\w +)
Hi, I''m writing a program with a large data stream to which modules can
connect using regular expressions.
Now I''d like to not have to test all expressions every time I get a line,
as most of the time, one of them having a match means none of the others
can have so.
But ofcource there are also cases where a regular expression can
"contain" another expression, like in:
"^strange line (\w+) and (\w+)
这篇关于比较正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!