I currently have the following string in java:
"Blah, blah, blah,~Part One, Part Two~,blah blah"
I need to remove the comma between the ~ character so it reads.
"Blah, blah, blah,~Part One Part Two~,blah blah"
Can anyone help me out please?
Many thanks,
The above prints:
How it works
There are 4 cases:
~, so next time we’ll be “inside”(^[^~]*~)~till the end of the string~, we’ll be “outside”([^~]*$)~(so we’re still “inside”)([^,~]*),(don’t capture the comma!)~instead of a comma, then go out, then go back in on the next~([^,~]*~[^~]*~)In all cases, we make sure we capture enough to reconstruct the string.
References
Related questions