The title may sound odd, but im kind of trying to set up this preg_replace that takes care of messy writers for a textarea. It has to:
- if there is an exclamation sign, there should not be another one in a row.
- if there is a ., the comma wins and it has to be ,
- when there is one+ spaces before a coma, it should be reduced to nothing.
- the sentence cannot start or end with a comma.
- there should never be more than 2 of the same letters joined together.
- a space must be always present after a comma.
E.g.:
- ,My house, which is green., is nice!
- My house..., which is green, is nice!!!
- My house ,which is green,,, is nice!!
The end result should always be:
My house, which is green, is nice!
Is there an already built regex that takes care of this?
Solution check out FakeRainBrigand's solution below!