Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- # Has Vowels
- def has_vowels(string):
- return bool(re.search(r'[aeiou]', string))
- # Is Integer
- def is_integer(string):
- return bool(re.search(r'^-?[0-9]+$', string))
- def is_integer(string):
- return bool(re.search(r'^-?\d+$', string))
- # Is Fraction
- def is_fraction(string):
- return bool(re.search(r'^-?[0-9]+/0*[1-9]+[0-9]*$', string))
- def is_fraction(string):
- return bool(re.search(r'^-?\d+/\d*[1-9]+\d*$', string))
- # Valid Time
- def is_valid_time(string):
- return bool(re.search(r'([0-1]\d|2[0-3]):[0-5]\d', string))
- # Valid Date
- def is_valid_date(string):
- return bool(re.search(r'\d{4}-[01]\d-[0-3]\d', string))
- def is_valid_date(string):
- return bool(re.search(r'''
- (19|20) \d \d
- -
- ( 0[1-9] | 1[0-2] )
- -
- ( 0[1-9] | [12]\d | 3[01] )
- ''', string, re.VERBOSE))
- # Tetravocalic
- re.findall(r'\b.*[aeiou]{4}.*\b', dictionary)
- # Hexadecimal Words
- re.findall(r'\b[0-9a-f]+\b', dictionary)
- re.findall(r'\b[a-f\d]+\b', dictionary)
- # Nexaconsonantal
- re.findall(r'\b.*[^aeiouy\s]{6}.*\b', dictionary)
- re.findall(r'\b.*[bcdfghjklmnpqrstvwxz]{6}.*\b', dictionary)
- # Crossword Helper
- def possible_words(partial_word):
- pattern = r'\b{}\b'.format(partial_word.replace('_', '.'))
- return re.findall(pattern, dictionary, re.IGNORECASE)
- # Repeat Letter
- re.findall(r'\b.*n.*n.*n.*n.*n.*\b', dictionary)
- re.findall(r'\b(?:.*n.*){5}\b', dictionary)
Add Comment
Please, Sign In to add comment