Initialize and compile regular expression for category groups

    :param category_regex_args:         List of string regex

    :return:                            List of compiled regex
179714
def init_group_category_regex(category_groups, category_regex_args):
    
    category_regex = []
    authorized_empty_regex = 1
    if len(category_regex_args) and len(category_groups) != len(category_regex_args):
        printError('Error: you must provide as many regex as category groups.')
        return None
    for regex in category_regex_args:
        if len(regex) < 1:
            if authorized_empty_regex > 0:
                category_regex.append(None)
                authorized_empty_regex -= 1
            else:
                printError('Error: you cannot have more than one empty regex to automatically assign groups to users.')
                return None
        else:
            category_regex.append(re.compile(regex))
    return category_regex
166427
def build_tree_parser(patterns):
    
    def output():
        for pattern in patterns:
            yield (pattern.build_full_tree(), pattern.regex)
    return list(output())
122072
def register_regex_entity(self, regex_str):
        
        if regex_str and regex_str not in self._regex_strings:
            self._regex_strings.add(regex_str)
            self.regular_expressions_entities.append(re.compile(regex_str, re.IGNORECASE))
926321
def _process_regex(cls, regex, rflags, state):
        """"""
        if isinstance(regex, Future):
            regex = regex.get()
        return re.compile(regex, rflags).match
66301
function handleArgs (_regex, _config) {
	/* Identify regex pattern. */
	let pattern;
	if (_regex) {
		if (typeof _regex === 'string') {
			pattern = _regex;
		} else {
			try {
				pattern = _regex.source;
			} catch (e) {
				log(`Invalid regex:`);
				log(_regex);
			}
		}
	} else {
		log(`Invalid regex: none provided`);
	}
	if (!pattern) {
		let errObj = { msg: 'Invalid args' };
		throw errObj;
	}

	/* Identify config. Accept a variety of flavors and fall back to defaults as needed. */
	let config = {};
	if (!_config) {
		config.server = defaultServerConfig;
		config.cache = defaultCacheConfig;
	} else {
		config.server = handleServerConfig(_config.server);
		config.cache = handleCacheConfig(_config.cache);
	}

	return [pattern, config];
}
30030
def match(pattern, sentence, *args, **kwargs):
    
    return compile(pattern, *args, **kwargs).match(sentence)
93792
def _regexp(expr, item):
    ''' 
    '''
    reg = re.compile(expr)
    return reg.search(item) is not None
374633
def _GetParsersFromPresetCategory(cls, category):
    
    preset_definition = cls._presets.GetPresetByName(category)
    if preset_definition is None:
      return []

    preset_names = cls._presets.GetNames()
    parser_names = set()

    for element_name in preset_definition.parsers:
      if element_name in preset_names:
        category_parser_names = cls._GetParsersFromPresetCategory(element_name)
        parser_names.update(category_parser_names)
      else:
        parser_names.add(element_name)

    return sorted(parser_names)
508391
def match(self, category, pattern):
        """"""

        return fnmatch.fnmatch(category, pattern, flags=self.FNMATCH_FLAGS)
687546
def prep_regex(patterns):
    """"""

    flags = 0 if Config.options.case_sensitive else re.I

    return [re.compile(pattern, flags) for pattern in patterns]
1335326
def _construct_regex(cls, fmt):
        """"""
        return re.compile(fmt.format(**vars(cls)), flags=re.U)
167694
def build_regex(self, tokens):
        """"""
        patterns = []
        for token in tokens:
            patterns.append(token.pattern_start)
            if token.pattern_end:
                patterns.append(token.pattern_end)
        return re.compile('|'.join(patterns), re.DOTALL)
526462
def get_category_lists(self, init_kwargs=None, additional_parents_aliases=None):
        

        if self._category_editor is not None:  # Return editor lists instead of plain lists if it's enabled.
            return self._category_editor.get_lists()

        from .toolbox import get_category_lists
        init_kwargs = init_kwargs or {}

        catlist_kwargs = {}
        if self._category_lists_init_kwargs is not None:
            catlist_kwargs.update(self._category_lists_init_kwargs)
        catlist_kwargs.update(init_kwargs)

        lists = get_category_lists(catlist_kwargs, additional_parents_aliases, obj=self)

        return lists
662873
def method_missing(meth, *args, &block)

      if @categories.include?(meth)

        if block_given?
          args[0] = yield block
        end

        self::msg(meth, args[0])

      else
        super
      end

    end
1172675
def make_regex(separator):
    
    return re.compile(r'(?:' + re.escape(separator) + r')?((?:[^' +
                      re.escape(separator) + r'\\]|\\.)+)')
1373801
def getmatch(self, regex, group=0, flags=0):
    

    match = self.match(regex, flags)
    if match:
      return match.group(group)
    return None
1360263
def _regex_to_static(src, regex):
    '''
    
    '''
    if not src or not regex:
        return None

    try:
        compiled = re.compile(regex, re.DOTALL)
        src = [line for line in src if compiled.search(line) or line.count(regex)]
    except Exception as ex:
        raise CommandExecutionError("{0}: '{1}'".format(_get_error_message(ex), regex))

    return src and src or []