【发布时间】:2014-11-05 12:34:02
【问题描述】:
我有一个正则表达式,它匹配所有不包含't's 或至少包含一个不在序列'th' 中的't' 的行。我想反转它,以便它只匹配那些包含 'th' 但不包含其他 't' 的行。
^.*?t(?!h).*?$|^[^t]+$
这是一个示例输入。表达式 currents 匹配所有带 + 号的行。
thought +1
though -1
without +2
within -2
tenth +3
thoth -3
tents +4
sample +5
thirteenth +6
如何编写带有负前瞻的表达式,使其仅匹配带有 - 符号的行?
【问题讨论】:
标签: regex regex-negation regex-lookarounds