-3

I need a regrex to get the value in the below format

Code=ABC&cellNo=314&payType=0&transmission=MANUAL&vendorId=ET&toggleSelctd=0&uniqueId=39

This is a sample code is attached in the below screenshot

but however the regrex which i have created fetches data for one value but i need the same in the above format, for example below are the regrex.

  1. name="cellNo" type="hidden" value="(.+?)" value="(.+?)
  2. name="transmission" type="hidden" value="(.+?)"

Thanks 1

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Richa Yadav
  • 49
  • 10
  • 2
    what have you tried and what exactly you want to get? – Ori Marko Aug 08 '17 at 12:20
  • @user7294900 : i have tried to fetch the data using each one regexr which is working fine but incase of such getting data in this combination i am not able to fetch it – Richa Yadav Aug 08 '17 at 12:23
  • @user7294900 : Like this one :name="cellNo" type="hidden" value="(.+?)" value="(.+?) and name="payType" type="hidden" value="()" and name="transmission" type="hidden" value="(.+?)" but unable to get in the above set of combination – Richa Yadav Aug 08 '17 at 12:23
  • in case of value="" what you want it to return? – Ori Marko Aug 08 '17 at 12:27
  • @user7294900 : the value which is mention for ex name="transmission" type="hidden" value="(.+?)" .. this value contains "MANUAL" like that – Richa Yadav Aug 08 '17 at 12:35
  • guys please dont downvote this question i m really new into this and in need of this solution.. i am updating this question in much more simpler way.. for you guys to look for hence added directly the screenshot – Richa Yadav Aug 08 '17 at 12:44
  • Maybe you should remove those duplicate attributes first. i.e. regex replace `((\w+)="[^"]+"\s+)\2="[^"]*"\s*` by `$1`. Then use an xml parser to get the name and value attributes. – LukStorms Aug 08 '17 at 12:44
  • @LukStorms : ohk.. and what if want this in regex is then like .. the one above i mention. – Richa Yadav Aug 08 '17 at 12:47
  • Anyway, using `value="(.+?)" value="(.+?)"` on a string that has `"value="ET" value=""` won't work because it expect at least one character between the quotes in the second value. – LukStorms Aug 08 '17 at 12:53
  • @LukStorms : ohk.... – Richa Yadav Aug 08 '17 at 12:55

1 Answers1

0

Don't use regular expressions to parse HTML. JMeter offers CSS/JQuery Extractor for fetching data from the HTML pages so you should be able to extract the required values using the following configurations:

  1. For MANUAL:

    • Reference Name: anything meaningful, i.e. transmission
    • CSS/JQuery Expression: input[id=transmission]
    • Attribute: value
  2. For 314
    • Reference Name: anything meaningful, i.e. CellNo
    • CSS/JQuery Expression: input[id=CellNo]
    • Attribute: value

See How to Use the CSS/JQuery Extractor in JMeter article for more information.


I think response markup is a little bit flaky as HTML input cannot have 2 name and 2 value tags, I would recommend using JMeter's HTML Assertion or online HTML Validator to check response data and raise issues on validation errors.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133