java - Looking for one-liner to remove multiple sub-string -


i have string contains 2 sub-strings:

sub_string1 = 123; sub_string2 = 456;  full_string = "456".concat(sub_string1).concat(sub_string2); 

later want remove sub_string1 , sub_string2 full_string.

my current method cumbersome:

string removed1 = full_string.replace(sub_string1, ""); string removed2 = removed1.replace(sub_string2, ""); 

i looking 1 liner solve problem, suggestions?

you can use regex remove multiple occurence of string using matches either token

string sub_string1 = "123"; string sub_string2 = "456";  string finals = "456df123".replaceall(sub_string1 +"|"+sub_string2 , ""); //or //string finals = "456df123".replaceall("456|123" , ""); system.out.println(finals); 

result:

df