Skip to content Skip to sidebar Skip to footer

Imacros Extract And Remove Unwanted Text

Hi Im trying to extract a price and strip the extract of some unwanted text. So that 'US $149.99' becomes '149.99' TAG POS=1 TYPE=SPAN FORM=NAME:donasub ATTR=ID:donaprice EXTRACT=T

Solution 1:

You need to escape special characters with \\. In this case it is "$"

SET donaprice EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"US \\$\", \"\");")

'show your result before saving in prompt (popup box) good for checking results

PROMPT {{donaprice}}

You are re-saving the original extract which is US $149.99 in this line:

`SAVEAS TYPE=EXTRACT FOLDER=C:\demo FILE=donafiles.csv`

You have to re-add the new variable "donaprice" to EXTRACT

ADD !EXTRACT {{donaprice}}

SAVEAS TYPE=EXTRACT FOLDER=C:\demo FILE=donafiles.csv


So all together :

SET donaprice EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"US \\$\", \"\");")

ADD !EXTRACT {{donaprice}}

SAVEAS TYPE=EXTRACT FOLDER=C:\demo FILE=donafiles.csv

Hope this helps.


Solution 2:

SET !EXTRACT EVAL("var s = '{{!EXTRACT}}'.replace(/US \\$/, ''); s;")

Post a Comment for "Imacros Extract And Remove Unwanted Text"