gpt4 book ai didi

Java - 正则表达式问题

转载 作者:行者123 更新时间:2023-12-02 08:33:19 25 4
gpt4 key购买 nike

Possible Duplicate:
Java - Regex problem

我有以下类型的 URL 列表:

  • http://www.example.com/pk/etc
  • http://www.example.com/pk/etc/
  • http://www.example.com/pk/etc/etc

哪里etc可以是任何东西。

所以我只想搜索那些包含www.example.com/pk/etc的URL或www.example.com/pk/etc/ .

Note: It is for all those who think that it is a duplicate question -- Kindly read both the questions carefully before marking this question as duplicate. Even after reading you can't understand that both the questions are different, then kindly leave without marking it as duplicate because I can't tell you the diff. in anymore detail

最佳答案

String pattern = "http://www.example.com/pk/[^/]+/?$";

我假设http://www.example.com/pk//不被接受。如果这也应该被接受,那么使用

String pattern = "http://www.example.com/pk/[^/]*/?$";

关于Java - 正则表达式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2661884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com