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
  • 12,055
  • 24
  • 120
  • 192
  • 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
  • 502,043
  • 27
  • 286
  • 360
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
  • 159,985
  • 5
  • 83
  • 133