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=TXT
SET donaprice EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"US $\", \"\");")
SAVEAS TYPE=EXTRACT FOLDER=C:\demo FILE=donafiles.csv
I still get the full string "US $149.99" in the extract. What am I not doing right.
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:
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.