-1

eregi_replace('[0-9]+\.+[0-9]','',$cart['unit']);

How to change it to preg_replace?

I get an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier '+' in ---

codemania
  • 1,098
  • 1
  • 9
  • 26

1 Answers1

0

You can use your existing Regex almost unchanged in a preg_replace(). Just add delimiters and a case-insensitive modifier. You get

preg_replace('#[0-9]+\.+[0-9]#i','',$cart['unit']);

In fact, the case-sensitivity is irrelevant since your pattern only matches 0-9 and .