Search code examples
regexcucumber

Regular expression not working inside string


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


Solution

  • Use this

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

    it should work.