Link to home
Start Free TrialLog in
Avatar of chambarish
chambarish

asked on

Nearest match RegEx

I have this text
(Objectid < 100 OR ObjectID > 500) AND (apple OR 10a) W/5 Bill

I want to get nearest string with in() having And Or in it nearest W/digit.

I want to get only (apple OR 10a) and not (Objectid < 100 OR ObjectID > 500) AND (apple OR 10a)

I m using
(?<DTVal>\(.*?(and|or|not).*?\))\s*(w|pre)/\d+\s*

Open in new window


But it brings back whole string instead of shortest.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chambarish
chambarish

ASKER

Yeps it works, however can I get regex in other case as well as in.

(test or best) W/5 AND (apple OR 10a) AND (Objectid < 100 OR ObjectID > 500) in the same reg EX.

In the above example I should get (test or best)  (apple OR 10a)
Thanks for your help.