?
Solved

Need to update regular expression in PHP

Posted on 2007-10-04
5
Medium Priority
?
176 Views
Last Modified: 2007-10-04
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);
0
Comment
Question by:MeridianManagement
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:MasonWolf
ID: 20014470
preg_replace('/\$(-)?[0-9]+\.[0-9]{2}/',"",$html);
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 20014496
Thanks Mason, you're always so quick
0
 
LVL 13

Accepted Solution

by:
MasonWolf earned 2000 total points
ID: 20014579
You're welcome. I actually wrote a little script that alerts me each time a new php question has been asked, and I leave it running whenever work's not too busy.
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 20014582
I haven't checked but I trust your solution is correct.
0
 
LVL 13

Expert Comment

by:MasonWolf
ID: 20014617
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.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, we’ll look at how to deploy ProxySQL.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question