DeveloperBreeze

Regex Development Tutorials, Guides & Insights

Unlock 1+ expert-curated regex tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your regex skills on DeveloperBreeze.

Cheatsheet
python

Python Regular Expressions (Regex) Cheatsheet

matches = re.findall(r'\d+', 'There are 12 apples and 5 oranges')
print(matches)  # Output: ['12', '5']

matches = re.finditer(r'\d+', 'There are 12 apples and 5 oranges')
for match in matches:
    print(match.group())  # Output: 12 5
result = re.sub(r'\d+', '#', 'There are 12 apples and 5 oranges')
print(result)  # Output: There are # apples and # oranges

result, num_subs = re.subn(r'\d+', '#', 'There are 12 apples and 5 oranges')
print(result, num_subs)  # Output: There are # apples and # oranges 2

Aug 03, 2024
Read More