Practice Problems - Advanced Regular Expressions¶
Create a regex that finds dates in the format MM/DD/YY or MM/DD/YYYY and returns just the year part.
Create a regex that finds phone numbers like 333-232-3403 or (333) 232 3403.
Create a regex that returns only the first alphabetic word (upper and lower case) at the start of the string.
Replace ‘YOUR_REGEX’ below with a regex that matches any price in the form of $3.45 or $23.32 or $400.
def find_price(content): return re.findall('YOUR_REGEX', content)
Create a regex below that captures a URL that only consists of characters, numbers, underscore, and dots. For example: www.abc.com, def_ghi.com, a678.cn Note that dots(“.”) should not appear consecutively, and should not appear as the first or last character. The dot must appear at least once.