1

My Response data is -

MyString=01015400007715243552T2867X01051005012447/3/1207/7\u0026index=2

MyString=014274X9000010152435500000MT2867X0154992365418/3/1207/7\u0026index=3

where i want to write a regex to match first string and ignore second string,below is my requirement.

As i highlighted in second string if the value contains X9 i should not match that string.

I tried many regex ,but dint help me much. i tried MyString=(.*[^X9].+?)u0026 Please can someone help me

shey
  • 282
  • 1
  • 5
  • 24

2 Answers2

1

You can try using the following regular expression:

MyString=(?:(?!X9).)*\\u0026

Demo:

JMeter Regular Expression Not Match

References:

Dmitri T
  • 119,313
  • 3
  • 56
  • 104
  • thanks for helping always :) please can u tell me more about the regex ..for my understanding ..thanks in advance – shey Dec 06 '17 at 06:11
1

The regex you may use is

MyString=((?:(?!X9).)*?)u0026

Or, to avoid matching in the backslash,

MyString=((?:(?!X9).)*?)\\u0026

Or, if \\u0026 is actually just a representation of & (and you have & in fact), use

MyString=((?:(?!X9)[^&])*)

The (?:(?!X9).)*? is a tempered greedy token that matches any char, any 0+ times, as few as possible, that does not start a X9 sequence.

Details

  • MyString= - a literal substring
  • ((?:(?!X9).)*?) - any char, 0+ repetitions, as few as possible (since *? is a lazy quantifier that forces the regex engine to skip the quantifyable pattern first and try all subsequent ones, and only if they fail to match this one is "expanded"), up to the first occurrence of X9
  • u0026 - a literal substring
Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397