Nearest match RegEx

Posted on 2012-08-27
Last Modified: 2012-08-27
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

Open in new window

But it brings back whole string instead of shortest.
Question by:chambarish
    LVL 74

    Accepted Solution



    Open in new window


    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now