cobrateam/flask-mongoalchemy · documents.py
python logo
def starting_with(self, letter):
        regex = r'^' + letter
        return self.filter({'title': re.compile(regex, re.IGNORECASE)})
Similar code snippets
1.
atsuoishimoto/tse · main.py
Match rating: 57.98% · See similar code snippets
python logo
def build_re(self, regex):
        if not regex:
            regex = '.*'
        flags = re.I if self.ignore_case else 0
        return re.compile(regex, flags)
2.
petermelias/valhalla · strings.py
Match rating: 57.3% · See similar code snippets
python logo
def regex(regex, case=False, _value=None, *args, **kwargs):
    if kwargs.get('case'):
        regex = re.compile(regex)
    else:
        regex = re.compile(regex, re.IGNORECASE)

    if not regex.match(_value):
        raise ValidationError('The _value must match the regex %s' % regex)

    return _value
3.
mcs07/ChemDataExtractor · selector.py
Match rating: 57.0% · See similar code snippets
python logo
def re(self, regex):
        if isinstance(regex, six.string_types):
            regex = re.compile(regex, re.U)
        text = self.extract()
        return flatten(regex.findall(text))
4.
rougeth/bottery · handlers.py
Match rating: 55.06% · See similar code snippets
python logo
def match(self, message):
        if not self.regex:
            self.regex = re.compile(self.pattern)

        if self.regex.match(message.text):
            return True
        return False
5.
ianmiell/shutit · shutit_util.py
Match rating: 54.8% · See similar code snippets
python logo
def check_regexp(regex):
	if regex is None:
		# Is this ok?
		return True
	try:
		re.compile(regex)
		return True
	except re.error:
		return False
6.
chorsley/python-Wappalyzer · Wappalyzer.py
Match rating: 54.57% · See similar code snippets
python logo
def _prepare_pattern(self, pattern):
        """
        Strip out key:value pairs from the pattern and compile the regular
        expression.
        """
        regex, _, rest = pattern.partition('\\;')
        try:
            return re.compile(regex, re.I)
        except re.error as e:
            warnings.warn(
                "Caught '{error}' compiling regex: {regex}"
                .format(error=e, regex=regex)
            )
            # regex that never matches:
            # http://stackoverflow.com/a/1845097/413622
            return re.compile(r'(?!x)x')
7.
spyder-ide/spyder · stringmatching.py
Match rating: 53.94% · See similar code snippets
python logo
def get_search_regex(query, ignore_case=True):
    """Returns a compiled regex pattern to search for query letters in order.

    Parameters
    ----------
    query : str
        String to search in another string (in order of character occurrence).
    ignore_case : True
        Optional value perform a case insensitive search (True by default).

    Returns
    -------
    pattern : SRE_Pattern

    Notes
    -----
    This function adds '.*' between the query characters and compiles the
    resulting regular expression.
    """
    regex_text = [char for char in query if char != ' ']
    regex_text = '.*'.join(regex_text)

    regex = r'({0})'.format(regex_text)

    if ignore_case:
        pattern = re.compile(regex, re.IGNORECASE)
    else:
        pattern = re.compile(regex)

    return pattern
8.
lotrekagency/djlotrek · djlotrek_filters.py
Match rating: 53.45% · See similar code snippets
python logo
def regex_match(value, regex):
    pattern = re.compile(regex)
    if pattern.match(value):
        return True
9.
rossant/ipymd · prompt.py
Match rating: 53.19% · See similar code snippets
python logo
def _starts_with_regex(line, regex):
    """Return whether a line starts with a regex or not."""
    if not regex.startswith('^'):
        regex = '^' + regex
    reg = re.compile(regex)
    return reg.match(line)
10.
estnltk/estnltk · common.py
Match rating: 52.88% · See similar code snippets
python logo
def is_valid_regex(regex):
    """Function for checking a valid regex."""
    if len(regex) == 0:
        return False
    try:
        re.compile(regex)
        return True
    except sre_constants.error:
        return False