You can try splitting the create-table statement on the regular expression [,()]|\s+. (The . is not part of the RE.) Then you need to look at the tokens that match the RE and at the strings between those tokens.
With this method, I needed about 400 lines of tcl to do a complete parse with error checking. If you are looking only for the PK, and you assume that the SQL statement is correct, it should be somewhat easier. Note that theoretically there can be pathological clauses like columnN char(100) default 'A PRIMARY KEY !!' not null, but maybe you can ignore those. If you can't ignore them, you'll have to count quotation marks. If you are going to do this in C, it will be a bit more tedious. The POSIX regex library doesn't really have a split function, but once you have the offsets and lengths of the matches, it should be easy to extract the strings in between -- or maybe you have (or can find) a regex library with a split function. A second possibility is to start an external program (written in python, perl, tcl, etc) as a pipe, and let it feed tokens to your program, or let it do the complete parse of the PK. A third possibility might be to adapt the parsing code in the SQLite source. Regards --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]