Guest User

Untitled

a guest
Dec 11th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. INSERT INTO `helppages`
  2. (`HelpPageID`, `ShowHelpItem`, `HelpRank`, `HelpCategory`, `HelpTitle`, `HelpDescription`, `HelpLink`, `HelpText`, `CMSHelpBar`, `CMSHelpBarAdditional`)
  3. VALUES (... characters (Too many to post here, but the expression below grabs all) ...
  4. );
  5.  
  6. preg_match("#INSERT INTO `$SearchingTableName` ([!%&'-/:<=>@^`;sdw"#$()*+,.?[]{}()\|©]*?));rn#s", $uploadedfile, $matches);
  7. which gets all the information but I can't get it to stop at the end ");rn"
  8. also $SearchingTableName = helppages.
  9.  
  10. preg_match("#INSERT INTO `$SearchingTableName` ([!%&'-/:<=>@^`;sdw"#$()*+,.?[]{}()\|©]*)(?!);rn)#s", $uploadedfile, $matches);
  11.  
  12. $pattern = <<<EOD
  13. ~
  14. # definitions
  15. (?(DEFINE)
  16. (?<elt> [^"',)]+ | '(?>[^\']+|\.)*' | "(?>[^\"]+|\.)*" )
  17. (?<list> ( g<elt>? (?: s* , s* g<elt> )* ) )
  18. )
  19.  
  20. # main pattern
  21. INSERT s+ (?:INTO s+)? `$SearchingTableName` s* g<list>? s* VALUES s*
  22. g<list> s* (?: , s* g<list> s* )* ;
  23. ~xs
  24. EOD;
  25.  
  26. if (preg_match_all($pattern, $uploadedfile, $m))
  27. print_r($m[0]);
  28.  
  29. [^"',)]+ # all that is not a quote a comma or a closing parenthese:
  30. # in the present context this will match numbers and column names
  31. | # OR
  32. '(?>[^\']+|\.)*' # string between single quotes (designed to deal with escaped quotes)
  33. |
  34. "(?>[^\"]+|\.)*" # same for double quotes
Add Comment
Please, Sign In to add comment