以下正则为什么能找到数字? 正则式 “[.$&)(\]\[\\~^%|*+?}{"' `#!-@=<>,;:/]+”,如果要匹配字符串"abshd{.^[]|" ;/we3~6t4~!ty"的话,匹配结果中会包含数字,这是为什么?我用Regex Match Tracer做的测试。 [解决办法] 别似乎,再认真查查资料。要确认,别靠记忆。 [解决办法]
-如果是第一个或者最后一个的话 不需要转义,否则还得加上转义 看regexbuddy的分析
[.$&)(\]\[\\~^% [解决办法] *+?}{"' `#!-@=<>,;:/]+
Match a single character present in the list below ?[.$&)(\]\[\\~^% [解决办法] *+?}{"' `#!-@=<>,;:/]+? Between one and unlimited times, as many times as possible, giving back as needed (greedy) ?+? One of the characters “.$&)(” ?.$&)(? A ] character ?\]? A [ character ?\[? A \ character ?\\? One of the characters “~^% [解决办法] *+?}{"' `#” ?~^% [解决办法] *+?}{"' `#? A character in the range between “!” and “@” ?!-@? One of the characters “=<>,;:/” ?=<>,;:/?