我在文件中有几个具有此模式的路径
/directory/dir/A/
/directory/dir/B/
/directory/dir/C/
/directory/dir/D/
我想要一个正则表达式模式用
替换它们/directory/dir/new-path-A/
/directory/dir/new-path-B/
/directory/dir/new-path-C/
/directory/dir/new-path-D/
由于
答案 0 :(得分:0)
搜索模式:
(/dir/)[^/]*
的更换:
$1new-path-
Java代码:
String repl = input.replacAll("(/dir/)[^/]*", "$1new-path-");