I have a string and I’m getting value through a html form so when I get the value it comes in a URL so I want to remove all the characters before the specific charater which is
= and I also want to remove this character. I only want to save the value that comes after
= because I need to fetch that value from the variable..
EDIT : I need to remove the
= too since I’m trying to get the characters/value in string after it…
You can use
String s = "the text=text"; String s1 = s.substring(s.indexOf("=") + 1); s1.trim();
s1 contains everything after
= in the original string.
.trim() removes spaces before the first character (which isn’t a whitespace, such as letters, numbers etc.) of a string (leading spaces) and also removes spaces after the last character (trailing spaces).
Answered By – ItamarG3
Answer Checked By – Dawn Plyler (BugsFixing Volunteer)