java - Regular expression with dynamic text -


i in java , need replace , need little regular expression.

string temp = "/users/john/core-xxx/testsomething.java" 

i using xxx place holder dynamic text. goal replace core-xxx text called testingplatform. help

so system.println(somenewvariable); should show

"/users/john/testingplatform/testsomething.java" 

you do

string newtemp = temp.replaceall("core-\\w+", "testingplatform"); 

where \w+ matches 1 or more word characters ([a-za-z_0-9])

filenames can contain unicode characters better

string newtemp = temp.replaceall("core-\\p{l}+", "testingplatform"); 

Comments