Possible Duplicate:
Tilde operator in Regular expressions
echo preg_replace_callback('~-([a-z])~', function ($match) {
return strtoupper($match[1]);
}, 'hello-world');
The code is from http://php.net/manual/en/functions.anonymous.php
I searched for what “~” is in regex and did not find an answer.
What does it do?
The first and last character of a regular expression in PHP (and other implementations) is known as the delimiter. Normally, you see a
/being used, but in this case, someone chose~. Read more here.Not sure why
~was chosen though; probably a habit of that particular developer. Normally, one chooses a different delimiter over/when the regular expression itself will contain slashes (e.g. matching URLs), so that slashes don’t need to be escaped every time.