Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Split SQL INSERT statement

  •  09-27-2007, 2:28 PM

    Split SQL INSERT statement

    Hello

    I have to parse a SQL INSERT statement to get all the values to include in the database.

    I thought that a regex should exist to do this, and I found this very nice regex (http://regexlib.com/REDetails.aspx?regexp_id=1750) :

    (INSERT INTO\s+)(\w+)(\s+\()([\w+,?\s*]+)(\)\s+VALUES\s+)((\(['?\w+'?,?\s*]+\)\,?;?\s*)+)

     

    Unfortunately,  it doesn't work with values containing other characters than letters.

    For exemple this insert request does not match :  INSERT INTO my_table (id, file) VALUES (1, 'file.java');

    Could you tell me how change the regex to match with values containing other characters than letters (for exemple : ' , . - < > ( ) ) ?

     

    Thanks a lot for your help !

     

     

     

View Complete Thread