imacros提取并删除不需要的文本

时间:2015-08-09 22:07:31

标签: javascript regex extract imacros extraction

嗨我试图提取价格并删除一些不需要的文本的摘录。那么" US $ 149.99"成为" 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"在提取物中。我做得不对。

2 个答案:

答案 0 :(得分:2)

您需要使用\\转义特殊字符。在这种情况下,它是“$”

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美元:

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

您必须将新变量“donaprice”重新添加到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

希望这有帮助。

答案 1 :(得分:0)

- (id)init{
if (!(self = [super init]))
    return nil;

//Setup the manager
manager = [[CLLocationManager alloc] init];
if (!manager) {
    return nil;
}
manager.distanceFilter = kCLDistanceFilterNone;
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
manager.desiredAccuracy = kCLLocationAccuracyBest;
manager.delegate = self;
if ([manager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
    manager.pausesLocationUpdatesAutomatically = NO;
}
if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
    [manager requestAlwaysAuthorization];
}

[manager startUpdatingLocation];

return self;
}