Is there a way to convert a string
"m1, m2, m3"
next
"m1/build, m2/build, m3/build"
only using the String.replaceAll(regex, replacement)
method?
So far this is my best attempt:
System.out.println("m1, m2, m3".replaceAll("([^,]*)", "$1/build")); >>> m1/build/build, m2/build/build, m3/build/build
As you can see, the output is incorrect. However, using the same regexp on Linux sed
gives the correct result:
echo 'm1, m2, m3' | sed -e 's%\([^,]*\)%\1/build%g' >>> m1/build, m2/build, m3/build
source share