2015-10-12 39 views
2

确切:精装:$79.99从硒元素中选择一个特定字符

这是总元素。我只需要获得价值$79.99

店/确切:精装:$ 79.99 /我storeEval
/storedVars['i'].search($79.99)/导致

我已经尝试了上述之一,但它无法正常工作。

回答

1

这里要做的最好的事情就是存储完整的元素,然后用正则表达式分解它。

所以在这里反映您的例子:

<tr> 
    <td>store</td> 
    <td>exact:Hardcover: $79.99</td> 
    <td>full</td> 
</tr> 
<tr> 
    <td>storeEval</td> 
    <td>storedVars['full'].match(/[^: ]+$/)</td> 
    <td>price</td> 
</tr> 
<tr> 
    <td>echo</td> 
    <td>${price}</td> 
    <td></td> 
</tr> 

这给下面的输出

[info] Playing test case Untitled 
[info] Executing: |store | exact:Hardcover: $79.99 | full | 
[info] Executing: |storeEval | storedVars['full'].match(/[^: ]+$/) | price | 
[info] script is: storedVars['full'].match(/[^: ]+$/) 
[info] Executing: |echo | ${price} | | 
[info] echo: $79.99 
[info] Test case passed 

有关信息如何在正则表达式是跌断参考here

相关问题