Link to home
Create AccountLog in
Avatar of MeridianManagement
MeridianManagementFlag for United States of America

asked on

Need to update regular expression in PHP

I have a preg_replace that removes monetary values from a website. Unfortunately, it doesn't pick up negative monetary numbers such as $-51.00. Just a small tweak but I don't know how to do it.

$html = preg_replace('/\$[0-9]+\.[0-9]{2}/',"",$html);
Avatar of MasonWolf
MasonWolf
Flag of United States of America image

preg_replace('/\$(-)?[0-9]+\.[0-9]{2}/',"",$html);
Avatar of MeridianManagement

ASKER

Thanks Mason, you're always so quick
ASKER CERTIFIED SOLUTION
Avatar of MasonWolf
MasonWolf
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I haven't checked but I trust your solution is correct.
If you have any problems, just ask in the continuing discussion window and I'll stick around until you've got it. But I really don't think you will. That's the expression for the problem you described.