Lesson 24 of 55 · Python
Regular Expressions
Duration: 20 minutes
Lesson 24 of 55 · Python
Duration: 20 minutes
re module enables powerful pattern‑matching with regular expressions. Patterns are defined as raw strings (r'...') to avoid escaping backslashes.\n\npython\nimport re\ntext = 'The price is $45.99.'\npattern = r'\d+\.\d{2}' # matches numbers like 45.99\nmatch = re.search(pattern, text)\nif match:\n print('Found price:', match.group())\n\n\nCommon functions: re.search(), re.match(), re.findall(), re.sub().\n