regular expression format url

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 18:55:12

问题


need help to write regular expression to take change urls

from: http://vermon.com/good/helping.html NOTE: good may change at times to something different

to: http://suresite.com/helping.html

PLEASE NOTE: I am changing the base url and taking out the word good


回答1:


You could try with Java:

System.out.println(
    "http://vermon.com/good/helping.html"
        .replaceAll("(http://)[^/]+/good(/.+)", "$1suresite.com$2"));

Output:

http://suresite.com/helping.html


来源:https://stackoverflow.com/questions/46369870/regular-expression-format-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!