Skip to main content
deleted 174 characters in body
Source Link
hoan
  • 1.1k
  • 8
  • 13

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ in String str2= str1.replaceAll("^", "\""); will match the starting position within the string. So if you want the ^ char, write \^

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 

the replaceAll() method consume a regex for the 1st argument.

the ^ in String str2= str1.replaceAll("^", "\""); will match the starting position within the string. So if you want the ^ char, write \^

Hope this code can help:

String str2= str1.replaceAll("\\^", "\""); 
deleted 19 characters in body
Source Link
hoan
  • 1.1k
  • 8
  • 13

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^ (in Java: "\\^")

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^ (in Java: "\\^")

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 
added 186 characters in body
Source Link
hoan
  • 1.1k
  • 8
  • 13

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^. (in Java: "\\^")

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\\\"""\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^.

Hope this code can help:

String str = "hello \"there"; String str1 = str.replaceAll("\\\"", "^"); 

the replaceAll() method consume a regex for the 1st argument.

String str2= str1.replaceAll("^", "\""); 

the ^ will match the starting position within the string. So if you want the ^ char, write \^ (in Java: "\\^")

Hope this code can help:

String str = "hello \"there"; System.out.println(str); // hello "there String str1 = str.replaceAll("\"", "^"); System.out.println(str1); // hello ^there String str2= str1.replaceAll("\\^", "\""); System.out.println(str2); // hello "there 
deleted 3 characters in body
Source Link
hoan
  • 1.1k
  • 8
  • 13
Loading
Precision about regex
Source Link
hoan
  • 1.1k
  • 8
  • 13
Loading
Source Link
hoan
  • 1.1k
  • 8
  • 13
Loading