Loading ...
Sorry, an error occurred while loading the content.
 

Re: Regular Expression Help

Expand Messages
  • Terence Monteiro
    Alessandro, On Fri, Apr 1, 2011 at 11:05 AM, Alessandro Antonello
    Message 1 of 6 , Mar 31, 2011
      Alessandro,

      On Fri, Apr 1, 2011 at 11:05 AM, Alessandro Antonello <antonello.ale@...> wrote:
      Hi, all.

      I have a problem building a regular expression for fields in a SQL UPDATE
      statement. The SET clause has the format as follows:

      field1 = 'value of field1', field2 = 'field\' 2 value'

      I have built a regular expression that can split the name of fields from its
      values. But when a value has an escaped single-quote the regular expression
      fails...

      This should work:

      /\(\w\+\)\s*=\s*\(\(\\'\|[^']\)*\)'

      1. You need to escape the +, (, ), | metacharacters
      2. The value part is 0 or more \' or [^'] sequences
       
      Regards, Terence.

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Terence Monteiro
      ... You ll need a after the s*. Depending on whether you want to capture the single quotes: / ( w + ) s*= s* ( |[^ ] )* Regards, Terence. -- You
      Message 2 of 6 , Mar 31, 2011
        On Fri, Apr 1, 2011 at 11:53 AM, Terence Monteiro wrote:
        /\(\w\+\)\s*=\s*\(\(\\'\|[^']\)*\)'

        You'll need a ' after the \s*. Depending on whether you want to capture the single quotes:

        \(\w\+\)\s*=\s*'\(\\'\|[^']\)*'

        Regards, Terence.

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Alessandro Antonello
        ... Man, you are a genius! Thanks a lot! -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
        Message 3 of 6 , Apr 1, 2011
          2011/4/1 Jürgen Krämer <jottkaerr@...>:
          > /\v(\w+)\s*\=\s*('(\\'|[^'])*'|\d+)/i

          Man, you are a genius!

          Thanks a lot!

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.