I have a little problem with regex. I want to clean up a string.
Currently I’m using the following regex:
preg_replace("/[^a-zA-Z0-9 _-]/", "", "Example1:2@32");
which gives me: “Example1232”
But the colon shouldn’t be replaced, too. I tried it already with:
preg_replace("/[^a-zA-Z0-9 _-:]/", "", "Example1:2@32");
but that doesn’t work. Can somebody help me?
You have to escape
-character