2017-02-19 34 views
0

表达式包含以下参数:定期提取给定一个HTTP响应头参数值

Content-Disposition: attachment; filename="myfile.pdf" 

是什么在JMeter的正则表达式来提取文件名myfile.pdf?我已从filename=".*"开始,但不知道如何继续。

+0

[学习正则表达式]的可能重复(http://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen

回答

1
  1. 所有你需要周围有像括号正则表达式的第一:

    filename=(.*) 
    

    这样的JMeter会知道究竟是什么你正试图捕捉。它会提取"myfile.pdf"

  2. 如果您不需要引号 - 将它们添加到您的正则表达式,如:

    filename="(.*)" 
    
  3. 请确保您有:

    • 现场检查: Response Headers
    • 模板:$1$

      JMeter Regular Expression Extractor configuration


参考文献:

+0

虽然@ tim-biegeleisen的答案完美无缺,但我选择了这个答案作为答案,因为的解释。 –

+0

如果您阅读JMeter文档,您会发现这个答案不是最有效的解决方案。 –

1

尝试使用这样的:

Content-Disposition: attachment; filename="([^"]+)" 

说明:

(  capture what follows 
[^"]+ any non quote character, one or more times 
)  stop capture