Find/replace prices between certain values

General discussions about Advanced Find and Replace
Post Reply
amenzl
Posts: 4
Joined: Mon Dec 11, 2006 5:11 am
Location: Oregon

Find/replace prices between certain values

Post by amenzl » Mon Dec 11, 2006 5:29 am

I am trying to figure out how to find and replace prices between certain values. A couple examples:

If product price is between (including equal to) $15.25 to $19.75 then change product price to $14.00.

If product price is between (including equal to) $.75 to $.99 then change product price to $.50.

These are just listed as an example. I appreciate someone finding a solution. This is an easy thing to accomplish in a database, but I have 1000's of static web pages to update and want to avoid having to rebuild them on the system I have now (workstation was stolen in October :( ).

Thank you!

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Mon Dec 11, 2006 5:06 pm

Go to main menu - Action - Options - Batch Replace
check "Modifier G"
check "Modifier E"

Go to Batch replace tab, check on "Use regular expressions".
Put 3 lines into the batch grid:

Search for:
(\$)\.(\d+)

Replace with:
${1}0.$2

Search for:
\$(\d*\.\d+)

Replace with:
$<%=IFF(($1>=15.25) AND ($1<=19.75),14.00,IFF(($1>=0.75) AND ($1<=0.99),0.50,$1))=%>

Search for:
(\$)0\.(\d+)

Replace with:
${1}.$2

Explanations:
With first pair it transforms all $.80 style prices into $0.80 style
prices. AFR should use leading zeros to process numbers.

With second pair it transforms the prices according to given ranges.
Note: IFF function is used, so you may use several ranges at once:
IFF(,,IFF(,,IFF(,,IFF(,,)))) and so on.

With the last pair it transforms $0.80 style prices back into $.80
style prices.

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

amenzl
Posts: 4
Joined: Mon Dec 11, 2006 5:11 am
Location: Oregon

Post by amenzl » Mon Dec 11, 2006 7:31 pm

This works great Roman! I only needed to use the second string to accomplish the update (Search=\$(\d*\.\d+) Replace=$<%=IFF(($1>=15.25) AND ($1<=19.75),14.00,IFF(($1>=0.75) AND ($1<=0.99),0.50,$1))=%)

However, I'm going to complicate the issue. Each page I'm updating has three products. The first two products always have the same price while the third is always more expensive. Can you show me how to modify the string to add x amount to the third product?

I appreciate your help.

Thank you

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Mon Dec 11, 2006 9:36 pm

Advanced Find and Replace can do this too. The best way: send to
support@abacre.com a sample source HTML file and resulting HTML file
("how it should be"). So we will send you right the regular expression.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest