public static function regexMatch($text, $regex, $charset = null)
    {
        if (!empty($charset)) {
            $regex = self::convertCharset($regex, $charset, 'utf-8');
            $text = self::convertCharset($text, $charset, 'utf-8');
        }

        $matches = array();
        foreach ($regex as $val) {
            if (preg_match('/' . $val . '/u', $text, $matches)) {
                break;
            }
        }

        if (!empty($charset)) {
            $matches = self::convertCharset($matches, 'utf-8', $charset);
        }

        return $matches;
    }
public static function regexMatch($text, $regex, $charset = null)
    {
        if (!empty($charset)) {
            $regex = self::convertCharset($regex, $charset, 'utf-8');
            $text = self::convertCharset($text, $charset, 'utf-8');
        }

        $matches = array();
        foreach ($regex as $val) {
            if (preg_match('/' . $val . '/u', $text, $matches)) {
                break;
            }
        }

        if (!empty($charset)) {
            $matches = self::convertCharset($matches, 'utf-8', $charset);
        }

        return $matches;
    }
public static function regexMatch ( $ text , $ regex , $ charset = null ) { if ( ! empty ( $ charset ) ) { $ regex = self :: convertCharset ( $ regex , $ charset , 'utf-8' ) ; $ text = self :: convertCharset ( $ text , $ charset , 'utf-8' ) ; } $ matches = array ( ) ; foreach ( $ regex as $ val ) { if ( preg_match ( '/' . $ val . '/u' , $ text , $ matches ) ) { break ; } } if ( ! empty ( $ charset ) ) { $ matches = self :: convertCharset ( $ matches , 'utf-8' , $ charset ) ; } return $ matches ; }
Performs a multibyte safe regex match search on the text provided.

@param string $text     The text to search.
@param array $regex     The regular expressions to use, without perl
regex delimiters (e.g. '/' or '|').
@param string $charset  The character set of the text.

@return array  The matches array from the first regex that matches.
Performs a multibyte safe regex match search on the text provided .