0
I tried that code but the $
is not understood as the end of the string, but rather as a character to be captured, I did something wrong or it’s a bug?
String s = "gabriel";
System.out.println(s.replace("iel$", ""));
0
I tried that code but the $
is not understood as the end of the string, but rather as a character to be captured, I did something wrong or it’s a bug?
String s = "gabriel";
System.out.println(s.replace("iel$", ""));
0
According to the documentation, the method replace
nay works with regular expressions.
What you want is the method replaceAll
. This yes works with regex:
String s = "gabriel";
System.out.println(s.replaceAll("iel$", "")); // gabr
Although in that particular case no need to regex:
String s = "gabriel";
System.out.println(s.replace("iel", ""));
Browser other questions tagged java regex
You are not signed in. Login or sign up in order to post.
MY HERO VLWWW
– inosivel