Q:

Replacing a special character (along with space is considered same)

Have a look at this string String str = "first,second, there"; . there are , and , ( there's a space after the second comma). How do I express it in RegEx as .replaceAll()'s parameters so the
output would be :
"first second there". <-- the amount on each space will be same.
I had tried some combinations but still fail. One of them is : 
String temp2 = str.replaceAll("[\\,\\, ]", " "); will print first second  there. 
Thanks before.

A:

Simply use , * to match comma followed by zero or more spaces and replace with single space.
String str = "first,second, there";
System.out.println(str.replaceAll(", *", " "));

output:
first second there

Read more about Java Pattern
Greedy quantifiers

X?  X, once or not at all
X*  X, zero or more times
X+  X, one or more times

