#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Smile Regular Expression to extract csrf_token in JMETER


    Hi,
    I am trying to extract the value of csrf_token in JMETER regular expression extractor from the following response content

    <meta
    http-equiv="refresh"
    content="9;
    URL=../view/.pending?tid=heaahwl8&source=/login/.login&polling_url=/login/pending_login.jsp&unique=heaahwl8&csrf_token=3798ef0c-d2d8-4ce2-8609-4a2a2e27eed3" >

    That is the value, 3798ef0c-d2d8-4ce2-8609-4a2a2e27eed3
    I tried
    csrf_token=([^"]+)
    but this returns the csrf along with it, and I just need the value.

    Thanks for any help!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    22
    Rep Power
    0
    Sounds like you are getting backtrace 0 (which is always the entire match instead of what you want, backtrace 1.

    How you specify that varies from language to language.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0
    It looks like that your regular expression is correct. I'd suggest to use $1$ as a "Template" in your Regular Expression Extractor Post Processor as it matches following:

    group 0 =csrf_token=3798ef0c-d2d8-4ce2-8609-4a2a2e27eed3
    group 1 =3798ef0c-d2d8-4ce2-8609-4a2a2e27eed3

    And you're interested in group 1.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    22
    Rep Power
    0
    my point exactly, but glinius said it better! kudos!

IMN logo majestic logo threadwatch logo seochat tools logo