Question

preg_replace ("/(\p{P})/", ' ', $str) removes apostrophes, and it should not. Please help

Was it helpful?

Solution

Try this:

/\p{P}(?<!')/

The additional look-behind assertion is to ensure that the punctuation character is not an apostrophe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top