【发布时间】:2015-02-26 02:33:47
【问题描述】:
抽象问题:
匹配不以 'char' 开头的字符串并返回匹配项。
我的正则表达式(不完美):
/(<XX>){1}([^#]*)(<\/XX>){1}/ig
会:
<XX>#test</XX> // not matched
<XX>test</XX> // matched + return 'test'
<XX>te#st</XX> // not matched
但应该这样做:
<XX>#test</XX> // not matched
<XX>test</XX> // matched + return test
<XX>te#st</XX> // matched + return te#st
加返回片段(即标签之间的组='test',例如'$2')。
【问题讨论】:
-
你用什么语言做这个?
-
javascript,不过没关系
-
您的要求是“匹配不包含字符的字符串”,# 是您要匹配的字符吗?
-
1.
string不包含#= 匹配 2. 返回此 (1)fragment的string
标签: javascript regex regex-negation