Java正则表达式问题
我对java正则表达式有一个问题。我有点像Java正则表达式问题,java,regex,Java,Regex,我对java正则表达式有一个问题。我有点像 com/products/id/response.html 我希望id为Aa Zz 0-9中的任何内容,我已尝试: com/products/A-Za-z0-9]+/response.html 但是没有成功,但是在这种情况下 com/products/A-Za-z0-9]+.html 它工作得很好。。。 你知道我在哪里出错了吗?你漏掉了第一个括号,所以它应该是这样的: com/products/[A-Za-z0-9]+/response[.]ht
com/products/id/response.html
我希望id为Aa Zz 0-9中的任何内容,我已尝试:
com/products/A-Za-z0-9]+/response.html
但是没有成功,但是在这种情况下
com/products/A-Za-z0-9]+.html
它工作得很好。。。
你知道我在哪里出错了吗?你漏掉了第一个括号,所以它应该是这样的:
com/products/[A-Za-z0-9]+/response[.]html
- 字符类是
,您缺少[…]
[
- 你得逃开点
- Jave需要
才能逃逸\
com/products/[A-Za-z0-9]+/response\\.html
- 您可能还需要使用锚定
和^
$