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
  • 92,520
  • 20
  • 182
  • 218
Shashank Jain
  • 838
  • 2
  • 10
  • 24

0 Answers0