1

This is my regex .+\s*(?=!|<|>|=|LIKE) and it doesnt work.

I want to match everything on the left side to the operators <,>,<=,>=,=,!=,LIKE.

Obviously my regex doesn't do the work so I am wondering if you could help me.

Check out what is wrong on this link: https://regex101.com/r/skRdTr/1 (it matches everything on the left side, including >,<,! if operator is <=,>=,!=)

3
  • regex has LIKE and you expect LESS in your second sentence. Am I missing something? Commented Mar 29, 2017 at 2:35
  • Try (\w+\s+)(=|LIKE|<|>|>=|<=|!=){1} Commented Mar 29, 2017 at 2:37
  • This should do it (.+?)(?=[!<>=]+|LIKE) Commented Mar 29, 2017 at 2:37

1 Answer 1

1

I found the answer: .+?\s*(?=!|<|>|=|LIKE).

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

2 Comments

.+? is the same as .* isn't it?
+? is "lazy match one or more" and .* is "greedy match zero or more". The OP's problem was with the two digit operators: The greedy left-side would capture the first digit, since the lookahead was happy to match the other. Also, @i_rezic the \s* portion of your regex isn't doing anything.

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.