开发者

Need help changing prices on multiple HTML pages, using regular expressions dreamweaver, want to multiply the price by 4

开发者 https://www.devze.com 2023-03-08 20:25 出处:网络
My task is simple. I want to replace all the prices (on HTML pages) marked by their value multiplied 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号