2

I have my query pattern as "^(select (skip \\d+)? (first \\d+))". I would like to match queries of type

1."SELECT * FROM X"
2."SELECT SKIP a FIRST b * FROM X"
3."SELECT SKIP a * FROM X"
4."SELECT FIRST B * FROM X"

The above regex i tried works fine for 1,2,3 but not for 4. Any ideas to what i should change the regex, so that all 4 patterns can be queried.

0

2 Answers 2

1
^select (?:skip \d+\s+)?(?:first \d+\s+)?\* from X$

You can use this.See demo.

https://regex101.com/r/oF9hR9/7

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the following regex to match all of these entries:

select\s*(?:skip\s*\d+)?\s*(?:first\s*\d+)?(?:\s*\*?\s*from\s+\d+)?

See demo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.