Reputation: 11
I am using the .replaceAll()
function in java and want to use a expression in it to achieve the bellow result.
Input:-,,2000,,399,600,,,678,,
Output:-2000,399,600,678
Upvotes: 0
Views: 153
Reputation: 67988
(?<=\\d)(,){2,}(?=\\d)|\\b,+\\B|\\B,+\\b
You can use this and replace by $1
.See demo.
https://regex101.com/r/eB8xU8/7
Upvotes: 2