/** * This only matches constant *strings* (things in quotes or marked for * translation). Numbers are treated as variables for implementation reasons (so that * they retain their type when passed to filters). * * @static * @return string */ public static function getReFilter() { if (self::$_re_filter === null) { $strdq = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"'; // double-quoted string $strsq = "\\'[^\\'\\\\]*(?:\\\\.[^\\'\\\\]*)*\\'"; // single-quoted string $i18n_open = '_\\('; $i18n_close = '\\)'; $constant_string = '(?:' . $i18n_open . $strdq . $i18n_close . '|' . $i18n_open . $strsq . $i18n_close . '|' . $strdq . '|' . $strsq . ')'; $num = '[-+\\.]?\\d[\\d\\.e]*'; $var_chars = '\\w\\.'; $filter_sep = preg_quote(self::FILTER_SEPARATOR); $arg_sep = preg_quote(self::FILTER_ARGUMENT_SEPARATOR); self::$_re_filter = '~^(?P<constant>' . $constant_string . ')|^(?P<var>[' . $var_chars . ']+|' . $num . ')|(?:' . $filter_sep . '(?P<filter_name>\\w+)(?:' . $arg_sep . '(?:(?P<constant_arg>' . $constant_string . ')|(?P<var_arg>[' . $var_chars . ']+|' . $num . ')))?)~'; } return self::$_re_filter; }