Page 1 of 1

Find/replace prices between certain values

Posted: Mon Dec 11, 2006 5:29 am
by amenzl
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!

Posted: Mon Dec 11, 2006 5:06 pm
by Abacre
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:

Replace with:

Search for:

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:

Replace with:

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.

Posted: Mon Dec 11, 2006 7:31 pm
by amenzl
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

Posted: Mon Dec 11, 2006 9:36 pm
by Abacre
Advanced Find and Replace can do this too. The best way: send to a sample source HTML file and resulting HTML file
("how it should be"). So we will send you right the regular expression.