I've got a file containing the DDL from a database. My goal is to pick it apart and create an XML file representing the structure that I can process further with XSLT.
A typical section I want to capture looks like this:
So the important facts, as I see them, are:
I want to start the capture on a line that begins with "CREATE TABLE"
I want to stop the capture where there are three consecutive new line characters
My regex coding works for me when selecting patterns on a single line. For example, this procedure will correctly print the names of all the tables in the document:
I have tried this pattern to capture the entire table definition, but the program doesn't print anything after several minutes of running.
I may have an issue with greedy matching when I want non-greedy matching, but I am rusty on REGEX and anyway, my biggest experience with it was in perl, where things are very different.
Please, can someone correct my pattern? Thanks
Alan Moore
Ranch Hand
Joined: May 06, 2004
Posts: 262
posted
0
Try this:
Charles Knell
Greenhorn
Joined: Mar 19, 2006
Posts: 25
posted
0
Thanks for your reply, but it did not produce a match.
Dave Wingate
Ranch Hand
Joined: Mar 26, 2002
Posts: 262
posted
0
Could you pre-process your content by: 1) replacing matches on 3 carriage returns with a symbol that's not commonly used in SQL, say, "^". 2) remove all remaining carriage returns.
I've never tried this, but thought it might be a simple (though inellegant) way to solve the problem.