1

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"]))
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
robert
  • 11
  • 2
  • Maybe `if (!preg_match('~^/[^./][^/]/*$~', $cfg["theme"]))`? – Wiktor Stribiżew Apr 29 '20 at 19:31
  • Well blow me down with a feather, and bless your cotton socks! I've been trying to work this out for hours and I get an answer within minutes on SO. Thanks a bunch! – robert Apr 29 '20 at 19:42
  • Does this answer your question? [How can I convert ereg expressions to preg in PHP?](https://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php) – Toto Apr 30 '20 at 10:05

1 Answers1

0

You may use

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

Pay attention to the regex delimiter, here, ~.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563