This sample regexp may be useful if you are working with DB field types.
(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))
For example, if you are have a such type as "varchar(255)" or "text", the next fragment
<?php
$type = 'varchar(255)'; // type of field
preg_match('/(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))/', $type, $field);
print_r($field);
?>
will output something like this:
Array ( [0] => varchar(255) [type] => varchar [1] => varchar [2] => (255) [length] => 255 [3] => 255 [4] => 255 )