Regular Expression to parse SQL Structure

Posted by user351429 on Stack Overflow See other posts from Stack Overflow or by user351429
Published on 2010-05-26T21:58:07Z Indexed on 2010/05/26 22:01 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

I am trying to parse the MySQL data types returned by "DESCRIBE [TABLE]".

It returns strings like:
int(11)
float
varchar(200)
int(11) unsigned
float(6,2)

I've tried to do the job using regular expressions but it's not working.

PHP CODE: $string = "int(11) numeric";
$regex = '/(\w+)\s*(\w+)/';
var_dump( preg_split($regex, $string) );

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql