Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Quote regular expression characters
<?php preg_quote(string $str, ?string $delimiter = null): string
<?php     final public function escapeStringForLike(string $inputString, string $escapeChar): string

    {

        return preg_replace(

            '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u',

            addcslashes($escapeChar, '\\') . '$1',

            $inputString

        );
<?php     private function parseColumnCollationFromSQL(string $column, string $sql): ?string

    {

        $pattern = '{(?:\W' . preg_quote($column) . '\W|\W'

            . preg_quote($this->_platform->quoteSingleIdentifier($column))

            . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is';
<?php     private function parseColumnCollationFromSQL(string $column, string $sql): ?string

    {

        $pattern = '{(?:\W' . preg_quote($column) . '\W|\W'

            . preg_quote($this->_platform->quoteSingleIdentifier($column))

            . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is';



        if (preg_match($pattern, $sql, $match) !== 1) {
<?php     {

        $pattern = '/\s* # Allow whitespace characters at start of line

CREATE\sTABLE # Match "CREATE TABLE"

(?:\W"' . preg_quote($this->_platform->quoteSingleIdentifier($table), '/') . '"\W|\W' . preg_quote($table, '/')

            . '\W) # Match table name (quoted and unquoted)

( # Start capture

   (?:\s*--[^\n]*\n?)+ # Capture anything that starts with whitespaces followed by -- until the end of the line(s)
<?php     private function parseColumnCommentFromSQL(string $column, string $sql): ?string

    {

        $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column))

            . '\W|\W' . preg_quote($column) . '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i';



        if (preg_match($pattern, $sql, $match) !== 1) {
<?php     private function parseColumnCommentFromSQL(string $column, string $sql): ?string

    {

        $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column))

            . '\W|\W' . preg_quote($column) . '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i';



        if (preg_match($pattern, $sql, $match) !== 1) {

            return null;