regular_expressions
上一篇 /
下一篇 2012-04-28 09:22:36
/ 个人分类:JMeter
\jmeter\printable_docs\usermanual\regular_expressions.html
20.2 Examples |
Extract single string
Suppose you want to match the following portion
of a web-page:
name="file" value="readme.txt" and you want to extract
readme.txt.
A suitable reqular expression would be:
name="file"
value="(.+?)" The special characters above are: - ( and ) - these enclose the portion of the match string to be returned
- . - match any character. + - one or more times. ? - don't be greedy, i.e.
stop when first match succeeds
Note: without the ?, the .+ would continue past the first " until it found
the last possible " - probably not what was intended. Extract multiple strings Suppose you want to match the following portion
of a web-page: name="file.name" value="readme.txt" and you want to extract
file.name and readme.txt.
A suitable reqular expression would be:
name="(.+?)" value="(.+?)"
This would create 2 groups, which
could be used in the JMeter Regular Expression Extractor template as $1$ and
$2$.The JMeter Regex Extractor saves the values of the groups in additional
variables. For example, assume: - Reference Name: MYREF
- Regex: name="(.+?)" value="(.+?)"
- Template: $1$$2$
|
收藏
举报
TAG: