imacros提取并删除不需要的文本 [英] imacros extract and remove unwanted text

查看:217
本文介绍了imacros提取并删除不需要的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试提取价格并剥离一些不需要的文本.这样"149.99美元"就变成了"149.99"

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

在摘录中,我仍然得到完整的字符串"US $ 149.99".我在做什么不对.

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}}

您将重新保存以下行中的原始摘录,即149.99美元:

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

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

您必须将新变量"donaprice"重新添加到EXTRACT

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

ADD !EXTRACT {{donaprice}}

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

所以在一起:

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

ADD !EXTRACT {{donaprice}}

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

希望这会有所帮助.

这篇关于imacros提取并删除不需要的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆