function ereg deprecated, how to update to preg_match?:

663 Views Asked by At

I'm using an old php script that runs on php 5.2 but host no longer provides php below 5.4 I'm getting an error regarding function ereg that needs to be updated to preg_match but I have no idea how this is done and a look around the web isn't too helpful. Any help available?

Existing code:

if (!ereg('^/[^./][^/]/*$', $cfg["theme"]))
1

There are 1 best solutions below

0
Wiktor Stribiżew On

You may use

 if (!preg_match('~^/[^./][^/]/*$~', $cfg["theme"]))

Pay attention to the regex delimiter, here, ~.