[英]Javascript regex: match any character that is not in the set of symbols (but only if this symbol doesn't follow a backslash)
I need a regex which matches any character that is not in the set of symbols (but only if this symbol doesn't follow a backslash)我需要一个匹配不在符号集中的任何字符的正则表达式(但前提是该符号不跟随反斜杠)
Is there any one line solution?有没有一条线的解决方案?
sample input: "Test1\,test2,test3\<\>test4<>test5"
样本输入:
"Test1\,test2,test3\<\>test4<>test5"
reqex to improve: /[^,<>]+/
reqex 改进:
/[^,<>]+/
Assuming \
is not at the first position of a match you may use this regex:假设
\
不在匹配的第一个 position 中,您可以使用此正则表达式:
[^,<>\\]+(?:\\.[^,<>\\]*)*
RegEx Details:正则表达式详细信息:
[^,<>\\]+
: Match 1 or more of any character that are not inside the the [...]
[^,<>\\]+
:匹配 1 个或多个不在[...]
范围内的任何字符\\.
match any escaped characterIf \
can be at first position then you may use:如果
\
可以首先是 position 那么你可以使用:
(?:\\.|[^,<>\\]+)+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.