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;
    }
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;
    }
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 ; }
Create partial regex to find given text not inside quotes.

@param string $string
@param bool $quote

@return string
Create partial regex to find given text not inside quotes .