Home > Software engineering >  Regular expression not working inside string
Regular expression not working inside string

Time:10-03

I need to validate JSON through cucumber and this JSON is generated run time. JSON is like below.

{
"k1":["A", "B1234"]
}

Here 1234 is any random number appended with B.

I am using below template to validate any JSON like above-

{
"k1":["A", "B[0-9] "]
}

But this is not working. I am getting message like Unable to validate JSON.

Any suggestion is highly appreciated.

Thanks

CodePudding user response:

Use this

{
"k1":["A", "B\[0\-9\]\ "]
}

it should work.

  • Related