抽象问题的开头字符:正则表达式匹配:不包含在一个字符串
匹配字符串不与“炭”启动和恢复比赛。
我正则表达式(不完美):
/(<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
加返回片段(即,标签之间的组='测试',例如'$ 2')。
问题例如: https://www.regex101.com/r/vT9kS7/1
你在做什么语言? – ryekayo
javascript,但没关系 – ziom
您的要求是“匹配不包含字符的字符串”,是您尝试匹配的字符数? – TWhite