2015-10-12 40 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

相關問題