protected function notInsideQuotes($string, $quote = true)
    {
        if ($quote) {
            $string = preg_quote($string);
        }

        return
            // double quotes - ignore "" and everything inside quotes for example " abc \"err "
            '(?:""|"(?:[^"]|\\")*?[^\\\]")(*SKIP)(*F)|' . $string .
            '|' .
            // single quotes - ignore '' and everything inside quotes for example ' abc \'err '
            '(?:\\\'\\\'|\'(?:[^\']|\\\')*?[^\\\]\')(*SKIP)(*F)|' . $string;
    }