0

I am trying to make a regex that matches filters as described in Microsoft RestAPI Guidelines. I have made this regex which does match a filter string:

(\(([\s]*(?:and|or|not)?[\s]*([\w]+)[\s]+(?:eq|ne|gt|ge|lt|le)[\s]+(?:"(?:[^"\\]|\\.)*"|\d+(,\d+)*(\.\d+(e\d+)?)?|null)[\s]*|(?R))*\))

But, it does not capture all the sub-patterns. For example, in this example string:

((priority eq "123" or en eq 34) and pre eq 1)

It returns two captures: (1) the entire string, (2) the last pattern and pre eq 1

I want to capture all the sub-patterns too. How can I do that?

Here is a link on Regex101: https://regex101.com/r/wH8iH1/8

Bakuriu
  • 98,325
  • 22
  • 197
  • 231
Shashank Jain
  • 847
  • 2
  • 10
  • 25

0 Answers0