Seems to be relatively simple task that gets me stuck in one PHP application. I have a string which has a bunch of
in it. Those are fine and need to stay there. However, there are also single occurrences of the character \
and those I need to replace or remove, let's just say with empty character without removing the ones that are followed by n
.
The best I came up with was to first replace all
with something else, some weird character, then replace the remaining \
with empty space and then convert back the weird character to
. However, that seems to be a waste of time and resources, besides, nothing guarantees me that I'll find weird enough character that will never be encountered in the rest of the string...
Any tips?