How can I match some part of request body?

912 views Asked by At

I am capturing request in stubby4j like this

-  request:
      method: POST
      url: /someUrl
      post: ".*(amit).*"

It works fine if I use single line in request body. E.g. User name is amit gupta. But it fails if I use multiline text as

User name is amit gupta 
secondline

How can I match some part of request body?

1

There are 1 answers

0
Wiktor Stribiżew On BEST ANSWER

Judging by the documentation, you just can use

"[\\s\\S]*(amit)[\\s\\S]*"

The [\s\S] construct matches any character that is either whitespace (\s) or non-whitespace (\S). Note that the parentheses around amit only make sense if you use the backreference to it later, thus, I'd remove these brackets.