.net - How to build a regular expression for nested search conditions -


i need build regular expression matching this:

"pqr , xyz or(abc or lmn)"

please me achieve this!

  1. it impossible regular expressions correctly match nesting.
    that, need context-free grammar.

  2. i see in comment, mentioned using .net.
    "regular expression" library in .net more powerful people call "regular expressions" in computer science.

    it is possible use .net regexes match nested parentheses using balancing-group definitions:

    \(   (?>       [^()]+     |       (?<depth>\()     |       (?<-depth>\))   )*   (?(depth)(?!)) \) 

    for pattern work you'll need ignore whitespaces.

    just aware this isn't available in every regular expression library , not regular expressions defined in computer science.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -