0

Given a HTTP response header contains the following parameter:

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

What's the regular expression in JMeter to extract the filename myfile.pdf? I've started with filename=".*" but don't know how to proceed.

Robert Strauch
  • 9,213
  • 17
  • 79
  • 138
  • Possible duplicate of [Learning Regular Expressions](http://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Feb 19 '17 at 16:07

2 Answers2

1

Try using this:

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

Explanation:

(      capture what follows
[^"]+  any non quote character, one or more times
)      stop capture
Tim Biegeleisen
  • 387,723
  • 20
  • 200
  • 263
1
  1. First of all you need to surround your regular expression with parentheses like:

    filename=(.*)
    

    so JMeter would know what exactly you are trying to capture. It will extract "myfile.pdf"

  2. If you don't need the quotation marks - add them to your regular expression like:

    filename="(.*)"
    
  3. Make sure you have:

    • Field to check: Response Headers
    • Template: $1$

      JMeter Regular Expression Extractor configuration


References:

Dmitri T
  • 119,313
  • 3
  • 56
  • 104