我正在使用 Java。我想检查 URL 中的正则表达式是否包含数字 id 等路径变量并将其替换为*.
我尝试了不同的模式,例如\/\d+.*,但没有得到我期望的结果。
input url: https://stackoverflow.com/questions/ask/123/456
expected output: https://stackoverflow.com/questions/ask/*/*
另一个:
input url: https://stackoverflow.com/questions/ask/123/456/find
expected output: https://stackoverflow.com/questions/ask/*/*/find
用“/*”替换“/”的正确正则表达式是什么?