Finally I made it to work by many trial and error, The Final Regex String is [^a-zA-Z\\s]s?(\\s)?
str.replaceAll("[^a-zA-Z\\s]s?(\\s)?", "$1");
Here is the Explanation,
[^a-zA-Z\\s]s?
=> Find all the special character except White space, follwed by one or zero s
(\\s)?
=> and immediately followed by a one or zero White space.
Here I grouped (\\s)
becoz I want to use that in the replaceAll()
function as 2nd Parameter to replace as $1
.
The Answer is
String orig = "Here is the world's first movie. #movie";`
System.out.println(orig..replaceAll("[^a-zA-Z\\s]s?(\\s)?", "$1"));
Final Output will be Here is the world first movie movie