J
John_Woo
Hi,
I'm trying to partially replace a string with a substring, like
old = "1..2..3..4"
new="1*2*3..4"
two ways to implement:
1. old.replaceAll ("\\..","*");
2. Pattern pattern = Pattern.compile("[..]{2}");
Matcher matcher = pattern.matcher(old);
matcher.replaceAll("*");
but these two result in
1*2*3*4
Can any one tell how to force to only replacing the first #1,2,
occurrances?
I'm trying to partially replace a string with a substring, like
old = "1..2..3..4"
new="1*2*3..4"
two ways to implement:
1. old.replaceAll ("\\..","*");
2. Pattern pattern = Pattern.compile("[..]{2}");
Matcher matcher = pattern.matcher(old);
matcher.replaceAll("*");
but these two result in
1*2*3*4
Can any one tell how to force to only replacing the first #1,2,
occurrances?