How can I convert ereg expressions to preg in PHP?

The biggest change in the syntax is the addition of delimiters. ereg(‘^hello’, $str); preg_match(‘/^hello/’, $str); Delimiters can be pretty much anything that is not alpha-numeric, a backslash or a whitespace character. The most used are generally ~, / and #. You can also use matching brackets: preg_match(‘[^hello]’, $str); preg_match(‘(^hello)’, $str); preg_match(‘{^hello}’, $str); // etc If … Read more