mardi 4 août 2015

Parse SQL INSERT-statement with RegEx

I need to parse SQL to get all:

  • Table names after INSERT clause,
  • Tables after FROM, JOINs (including CROSS JOIN as comma ',' operator) clauses,
  • The same with OPENQUERY or any other subqueries.

Each statement is one-liner SQL, without any extra spaces, comments, or new lines. Each query is INSERT-statement.

I have almost working regex: http://ift.tt/1HoUetJ.

But it has a problem: regex cathes only first FROM/JOIN statement. Or only last if I apply greedy quantificators.

Ideal result is syntax tree. But simple list of named group will be sufficient.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire