How to remove all characters before a specific character in Java?

You can use .substring():

String s = "the text=text";
String s1 = s.substring(s.indexOf("=") + 1);
s1.trim();

then s1 contains everything after = in the original string.

s1.trim()

.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).


While there are many answers. Here is a regex example

String test = "eo21jüdjüqw=realString";
test = test.replaceAll(".+=", "");
System.out.println(test);

// prints realString

Explanation:

.+ matches any character (except for line terminators)
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
= matches the character = literally (case sensitive)

This is also a shady copy paste from https://regex101.com/ where you can try regex out.