last day (26 days later) » 

9:07 AM
hello
 
Hi there
Gruesse nach Deutschland auch
 
how did you start that chat?
Danke :)
 
Just went to chat.stckexchange.com, made a new room
after searching for a regex room
 
ok, too easy for me :)
 
So I have this final regular expression to match a table:

public static function tables()
{
$pattern = '/(?<creationScript>CREATE\s+TABLE\s+`(?<tableName>\S+)`\s+';
$pattern .= '\((?<tableDefinition>([^;\/]+((COMMENT\s\'[^\']+((\'\')+[^\']*)*\')?[^;\/]+)*))\)';
$pattern .= '(?:\s+ENGINE=(?<engine>[^;\s]+))?\s*';
$pattern .= '(?:AUTO_INCREMENT=(?<autoIncrement>\d+))?\s*';
$pattern .= '(?:DEFAULT CHARSET=(?<defaultCharset>[^;\s]+))?\s*)';
$pattern .= '(?:COLLATE=.+?)?\s*';
$pattern .= '(?:\/\*.+?\*\/)?\s*';
And this is one table:
CREATE TABLE `jos_updates` (
`update_id` int(11) NOT NULL AUTO_INCREMENT,
`update_site_id` int(11) DEFAULT '0',
`extension_id` int(11) DEFAULT '0',
`name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '',
`description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`element` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '',
`type` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT '',
`folder` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT '',
`client_id` tinyint(3) DEFAULT '0',
of 3, which are not matches anymore at all
As per my question, this is the original code from the author of php-mysql-diff, which matches above table

public static function tables()
{
$pattern = '/(?<creationScript>CREATE\s+TABLE\s+`(?<tableName>\S+)`\s+';
$pattern .= '\((?<tableDefinition>[^;\/]+)\)';
$pattern .= '(?:\s+ENGINE=(?<engine>[^;\s]+))?\s*';
$pattern .= '(?:AUTO_INCREMENT=(?<autoIncrement>\d+))?\s*';
$pattern .= '(?:DEFAULT CHARSET=(?<defaultCharset>[^;\s]+))?\s*)';
$pattern .= '(?:COLLATE=.+?)?\s*';
$pattern .= '(?:\/\*.+?\*\/)?\s*';
But not this one:

CREATE TABLE `jos_ucm_history` (
`version_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ucm_item_id` int(10) unsigned NOT NULL,
`ucm_type_id` int(10) unsigned NOT NULL,
`version_note` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'Optional version name',
`save_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`editor_user_id` int(10) unsigned NOT NULL DEFAULT '0',
`character_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Number of characters in this version.',
 
9:10 AM
ok, lets take the sample text to regex101.com and add the parts of the regex line by line
I am working under this url: regex101.com/r/bM9zC7/1 - though I am afraid there is no way to host libe viewers
 
yup, organised my screens and will refresh
 
ok, first line worked ...
This will take a moment while I'll try to complement the tested regex one part in turn until it fails
 
ok
Otherwise, just paste all lines, half them until you find the breaking line
I see version 2. Did you find no issue with the actual column lines?
 
Ok, the current version is not procesed by the tester due to 'catastrophic backtracking behavior'; debugging on that ite seems to stall too.
 
AArgh
 
9:23 AM
I'll try a different version of the table expression regex
 
anyway I can help?
 
Thanks, at the moment I think you can't. I need to take the regex apart and fiddle with a couple of alternatives.
First result: a single comment id handled correctly
Next step: Getting multiple comments to work
 
9:56 AM
Ok, interim result: regex101.com/r/kV0zJ7/4
This one correctly matches the column definition part, with an arbitrary number of comments in between.
I had to distinguish the 2 cases of none and some comment in an alternation
 
FANTASTIC, can you update your answer and I will reference it in the pull request as well
sorry what is "interim" about it?
 
The trailing material had not yet been tested. But it seems ok, so far
 
sorry what do you mean by trailing material?
 
the table storage spec (averything after & including 'ENGINE')
Ok, cant spend more timeon it right now. Come back if there are any more difficulties
Bye
 
Yes thanks so much!
 

  last day (26 days later) »