Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.