mysql - SQL RegEx Create Split: Include SET -
i'm writing regex pattern split mysql create statements column definition arrays. far, works great aside set columns. here's process: $lines = explode("\n", $create_sql); foreach ($lines $line) { $line = str_replace('not null', 'not_null', $line); $pattern = '/`(.*)`[\s]*([^\s]*)[\s]*(not_null|null)[\s]*(.*),/'; $search = preg_match($pattern, $line, $matches); if ($search !== false && count($matches) === 5) { $columns[$matches[1]] = array( 'type' => $matches[2], 'null' => $matches[3] === 'null', 'extra' => $matches[4], ); } } this process works great on column definition this: `id` int(11) not null auto_increment, ...but fails on set columns. how can best accommodate quotes , parentheses in line? `platform` set('ios', 'android') null default n