Need help changing prices on multiple HTML pages, using regular expressions dreamweaver, want to multiply the price by 4
My task is simple. I want to replace all the prices (on HTML pages) marked by their value multiplied by 4.
开发者_C百科So $500 should become $2000. What would the code be for that?
Then I would like bigger prices, like $5000, to only be multiplied by 2 What would be the code for that?
That can't be done by a simple regex-replacement. Realize that a regex pattern does not match numbers (which can be operated on with +, -, etc.), but it matches strings.
The only possibility would be to replace \$5000
with \$10000
(the $
is a special char and needs to be escaped). I realize that with many different amounts, this is not a viable solution for you. However, if you have just a handful of different amount, you could do a couple of such replacements (be careful not to replace amounts twice!).
What you need is something like BeautifulSoup that knows about the structure of HTML.
精彩评论