How do i replace multiple words with an empty string "" in a string with java. I tried with for loop to replace those in single quotes by adding then in an array like below, but it replaces one word per printout.
String str = "this house 'is' really 'big' and 'attractive'.";
String[] values={"is","big","attractive"};
for(String s: values){
String replaced = str.replace(s, "");
System.out.println( replaced );
}
I'm getting this output:
> this house ' ' really 'big' and 'attractive'.
> this house 'is' really ' ' and 'attractive'.
> this house 'is' really 'big' and ' '.
What I need is this:
> this house ' ' really ' ' and ' '.