How to use the regex.fullmatch function in regex

To help you get started, we’ve selected a few regex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rooney / oprex / __init__.py View on Github external
def check_format(fmt):
        if not regexlib.fullmatch(r'o*\d+', fmt):
            raise OprexSyntaxError(t.lineno(0), "Bad number-range format: '%s'" % fmt)
        if regexlib.match(r'o+0+\d+', fmt):
            raise OprexSyntaxError(t.lineno(0), "Bad number-range format: '%s' (ambiguous leading-zero spec)" % fmt)
github 5j9 / wikitextparser / wikitextparser / _wikilist.py View on Github external
def __init__(
        self,
        string: Union[str, MutableSequence[str]],
        pattern: str,
        _match: Match = None,
        _type_to_spans: Dict[str, List[List[int]]] = None,
        _span: List[int] = None,
        _type: str = None,
    ) -> None:
        super().__init__(string, _type_to_spans, _span, _type)
        self.pattern = pattern
        if _match:
            self._match_cache = _match, self.string
        else:
            self._match_cache = fullmatch(
                LIST_PATTERN_FORMAT.replace(b'{pattern}', pattern.encode()),
                self._shadow,
                MULTILINE,
            ), self.string
github srix / pytamil / pytamil / தமிழ் / புணர்ச்சி.py View on Github external
def getmatchingவிதிகள்(நிலைமொழி, வருமொழி):
    தொடர்மொழி_விதிகள் =[]
    நிலைமொழிவிரி = எழுத்து.உயிர்மெய்விரி(நிலைமொழி)
    வருமொழிவிரி  = எழுத்து.உயிர்மெய்விரி(வருமொழி)

    for விதி in விதிகள்:
        if regex.fullmatch(விதி.நிலைமொழி_regex, நிலைமொழிவிரி ) and \
             regex.fullmatch(விதி.வருமொழி_regex, வருமொழிவிரி ):
             தொடர்மொழி_விதிகள்.append(விதி)

    # print(தொடர்மொழி_விதிகள்)
    return தொடர்மொழி_விதிகள்
github davidjurgens / equilid / equilid / equilid.py View on Github external
# If we only ever saw one language (easy case), then we've just screwed up
    # the number of tokens so iterate over the tokens and fill in the blanks
    if len(langs) == 1:
        lang = list(langs)[0]

        # This is the output set of assignments, based on realignment
        repaired = []    

        # Figure out where we have punctuation in the input
        for i, token in enumerate(tokens):
            if re.fullmatch(r"\p{P}+", token):
                repaired.append('Punct')
            elif re.fullmatch(r"#([\w_]+)", token):
                repaired.append('#Hashtag')
            elif re.fullmatch(r"@([\w_]+)", token):
                repaired.append('@Mention')
            elif (token.startswith('http') and ':' in token) \
                    or token.startswith('pic.twitter'):
                repaired.append('URL')
            else:
                repaired.append(lang)

        # print('%s\n%s\n' % (predictions, repaired))
                
        return repaired

    else:
        # NOTE: the most rigorous thing to do would be a sequence alignment with
        # something like Smith-Waterman and then fill in the gaps, but this is
        # still likely overkill for the kinds of repair operations we expect
github alan-turing-institute / CleverCSV / clevercsv / normal_form.py View on Github external
def is_elementary(cell):
    return not (
        regex.fullmatch("[a-zA-Z0-9\.\_\&\-\@\+\%\(\)\ \/]+", cell) is None
    )
github 5j9 / wikitextparser / wikitextparser / _wikilist.py View on Github external
def _match(self):
        """Return the match object for the current list."""
        cache_match, cache_string = self._match_cache
        string = self.string
        if cache_string == string:
            return cache_match
        cache_match = fullmatch(
            LIST_PATTERN_FORMAT.replace(b'{pattern}', self.pattern.encode()),
            self._shadow,
            MULTILINE)
        self._match_cache = cache_match, string
        return cache_match
github Zvezdin / blockchain-predictor / database_tools_old.py View on Github external
if args.peek:
			try:
				peekData(getChunkstore(), args.key)
			except:
				print("There was an error while peeking. Did you enter the correct key?")
		if args.read:
			try:
				readAllData(getChunkstore(), args.key)
			except:
				print("There was an error while reading. Did you enter the correct key?")
		if args.remove:
			try:
				key = args.key
		
				for dbkey in getChunkstore().list_symbols():
					if re.fullmatch(key, dbkey) is not None:
						removeDB(getChunkstore(), dbkey)
			except:
				print("There was an error while removing. Did you enter the correct key?")