我有一个正则表达式,所有的合法字符都经过精心选择并转义,但是它仍然无法捕获任何非法字符,例如:$&
etc:
val result = "http://example.com?re#k2$si".replaceAll("""[^0-9a-zA-Z!-_\.\*'\(\)]+""","/")
assert(url === "http/example.com/re/k2/si")
但结果是:
TestFailedException:“ http [://example.com?re#k2 $] si”不等于“ http [/example.com/re/k2/] si”
这里发生了什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句