2014-07-09 107 views
0

我有一個正則表達式調試取樣打印環境的JMeter的變量文件,system.properties等JMeter的正則表達式變量

然後我做一個正則表達式提取後處理如下: regex extractor postprocessing

不幸的是,當我爲場的正則表達式變量$ {regex}添加一個響應斷言,我在運行的視圖結果樹中得到空值。 response assertion

如何從null中得到正則表達式變量的值?

由於 格里特

回答

1

EDIT

使用後處理器>正則表達式提取,它是簡單的,以提取反應的任何部分。

由於JMeter的2.4,聽者查看結果樹包括一個RegExp測試儀直接在取樣響應數據


測試正則表達式可以使用以下方法:

Reference Name: regex 
Regular Expression: ([A-Z][a-z]) 
Template: $1$ 
Match No.: 1 

模板用於從找到的匹配中創建一個字符串。這是一個具有特殊元素的任意字符串,用於引用正則表達式中的組。因此,要引用組1,您可以使用$1$ ..

使用相應的變量來訪問匹配。 ${regex}

變量設置如下:

regex_matchNr - Number of matches found, possibly 0 
regex_n  - (n = 1, 2, etc..) Generated by the template 
regex_n_gm - (m = 0, 1, 2) Groups for the match (n) 
regex   - By itself it is always set to the default value 
regex_gn  - Not set at all 
+0

是的,謝謝!我認爲這也是它應該運作的方式。但是我的回覆聲明,現在對於變量$ {regex_1},仍然爲空... – Leder

+0

no'$ {regex}''$ {regex_1}'和'$ {FOO}'正常工作。我被卡住了。 – Leder

+0

@Leder看到更新的編輯。也許你錯過了一些東西,這對我很有用。 – hwnd