RudolfCardinal/pythonlib · sql_grammar.py
python logo
def sql_keyword(word: str) -> Regex:
    regex_str = word_regex_element(word)
    return make_pyparsing_regex(regex_str, caseless=True, name=word)
Similar code snippets
1.
RudolfCardinal/pythonlib · sql_grammar.py
Match rating: 68.22% · See similar code snippets
python logo
def make_words_regex(words_as_string_or_list: Union[str, List[str]],
                     caseless: bool = False,
                     name: str = None,
                     debug: bool = False) -> Regex:
    regex_str = multiple_words_regex_element(words_as_string_or_list)
    if debug:
        log.debug(regex_str)
    return make_pyparsing_regex(regex_str, caseless=caseless, name=name)
2.
RudolfCardinal/pythonlib · sql_grammar.py
Match rating: 66.76% · See similar code snippets
python logo
def make_regex_except_words(word_pattern: str,
                            negative_words_str_or_list: Union[str, List[str]],
                            caseless: bool = False,
                            name: str = None,
                            debug: bool = False) -> Regex:
    # http://regexr.com/
    regex_str = r"(?!{negative}){positive}".format(
        negative=multiple_words_regex_element(negative_words_str_or_list),
        positive=(WORD_BOUNDARY + word_pattern + WORD_BOUNDARY),
    )
    if debug:
        log.debug(regex_str)
    return make_pyparsing_regex(regex_str, caseless=caseless, name=name)
3.
RudolfCardinal/pythonlib · sql_grammar.py
Match rating: 66.05% · See similar code snippets
python logo
def make_pyparsing_regex(regex_str: str,
                         caseless: bool = False,
                         name: str = None) -> Regex:
    flags = re.IGNORECASE if caseless else 0
    result = Regex(regex_str, flags=flags)
    if name:
        result.setName(name)
    return result
4.
MycroftAI/adapt · engine.py
Match rating: 64.49% · See similar code snippets
python logo
def register_regex_entity(self, regex_str):
        """
        A regular expression making use of python named group expressions.

        Example: (?P<Artist>.*)

        regex_str(str): a string representing a regular expression as defined above
        """
        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))
5.
jkehler/unshortenit · module.py
Match rating: 63.19% · See similar code snippets
python logo
def _build_domain_regex(self):
        regex_str = r'^(' + r'|'.join(self.domains) + r')$'
        regex_str = re.sub(r'\.', '\.', regex_str)
        self._domain_regex = re.compile(regex_str)
6.
webrecorder/pywb · regex_rewriters.py
Match rating: 61.36% · See similar code snippets
python logo
def compile_rules(rules):
        # Build regexstr, concatenating regex list
        regex_str = '|'.join(['(' + rx + ')' for rx, op, count in rules])

        # ensure it's not middle of a word, wrap in non-capture group
        regex_str = '(?<!\w)(?:' + regex_str + ')'

        return re.compile(regex_str, re.M)
7.
ouroboroscoding/format-oc-python · __init__.py
Match rating: 61.2% · See similar code snippets
python logo
def regex(self, regex = None):
		"""Regex

		Sets or gets the regular expression used to validate the Node

		Arguments:
			regex {str} -- A standard regular expression string

		Raises:
			ValueError

		Returns:
			None | str
		"""

		# If regex was not set, this is a getter
		if regex is None:
			return self._regex

		# If the type is not a string
		if self._type != 'string':
			sys.stderr.write('can not set __regex__ for %s' % self._type)
			return

		# If it's not a valid string or regex
		if not isinstance(regex, (basestring, _REGEX_TYPE)):
			raise ValueError('__regex__')

		# Store the regex
		self._regex = regex
8.
thautwarm/RBNF · _literal_matcher.py
Match rating: 60.73% · See similar code snippets
python logo
def make_regex_matcher(regex_template: str):
    regex = re.compile(regex_template)

    def match(token: Tokenizer):
        return regex.match(token.value)

    match.raw = (ConstStrPool.cast_to_const("auto_regex"), regex_template)

    return match
9.
Neurita/boyle · strings.py
Match rating: 60.57% · See similar code snippets
python logo
def is_fnmatch_regex(string):
    """
    Returns True if the given string is considered a fnmatch
    regular expression, False otherwise.
    It will look for

    :param string: str

    """
    is_regex = False
    regex_chars = ['!', '*', '$']
    for c in regex_chars:
        if string.find(c) > -1:
            return True
    return is_regex
10.
RudolfCardinal/pythonlib · drugs.py
Match rating: 59.99% · See similar code snippets
python logo
def regex(self) -> Pattern:
        """
        Returns a compiled regex for this drug.
        """
        if self._regex is None:
            self._regex = re.compile(self.regex_text,
                                     re.IGNORECASE | re.DOTALL)
        return self._regex