Results 1 to 3 of 3

Thread: Regular Expression Question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521

    Regular Expression Question

    I want to match insert statements that have a select clause instead of a values clause. (i.e. "insert into... select * from ..." but not "insert into ... values(...)"

    I use the following regular expression:
    \binsert\b(?:.|\n)+?(?!values)\bselect\b

    I thought that the (?!values) would tell the parser to stop if it hit the string "values", but perhaps I do not fully understand negative lookaheads...

    Is there any way I can accomplish my goal?

    BTW, disable smilies unless you want some weird looking regular expressions ;)

  2. #2
    Lively Member
    Join Date
    Oct 2002
    Posts
    67
    Could you elaborate?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Transact SQL (and perhaps ANSI SQL) allows for at least two versions of the INSERT statement.

    Insert [into] table1 (column1, column2, ...) values (value1, value2, ...)

    and

    Insert [into] table1 (column1, column2, ...) select columnA, columnB, ... from tableA

    I was trying to build a regular expression that would match the second type of INSERT statement, but not the first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width