Hi marcnyc
I don't think you can do this in one line, more like three.
Do you want to do this after the <,>,&,'," and non-breaking spaces have been encoded by htmlspecialchars, or before?
If after then this should work:
PHP Code:
$interview = preg_replace("(/&[^;]+;)/si","\\1^",$interview);
$interview = preg_replace("/(;)[^\^]/si","\\1 ",$interview);
$interview = preg_replace("/(;)\^"/si","\\1",$interview);
This replaces any ; that you want to keep with ;^, then adds spaces to all the other ; and then reverts the first set of ;^ back to ;, assuming that the original string doesn't have any of these.
I haven't tested this code, but you should be able to use the idea to solve your problem.
Paul
Bookmarks