Match regex pattern when not inside a set of quotes (text spans multiple lines)

后端 未结 1 1116
悲&欢浪女
悲&欢浪女 2021-01-22 23:48

This is a continuation of my previous question .NET regex engine returns no matches but I am expecting 8.

My query is handling everything perfectly and I have my capture

相关标签:
1条回答
  • 2021-01-23 00:23

    An expression like this would match such quotes:

    (?:'[^']*')+
    

    If you want to match foo when it's not inside such quotes, you could use something like:

    foo(?=[^']*(?:'[^']*'[^']*)+\z)
    

    one match per line with the unquoted text and numbers as capture groups

    Something like this:

    (?xm)^
    \(
    
    (?:
        (?:
            (?<quote> (?:'[^']*')+ )
        |   (?<num>   -?\d+(?:\.\d+)? )
        |   (?<x>     X'[0-9a-f]*' )
        )
        (?:\s*,\s*)?
    )+
    
    \)
    [;,] 
    \r?$
    
    0 讨论(0)
提交回复
热议问题