DeveloperBreeze

Regular Expressions Development Tutorials, Guides & Insights

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

Understanding Regular Expressions with `re` in Python

Tutorial October 24, 2024
python

import re

# Pattern to match integers with optional sign
pattern = r"[+-]?\d+"

# Example text containing integers
text = "The numbers are +42, -17, and 100."

matches = re.findall(pattern, text)
print(matches)  # Output: ['+42', '-17', '100']
  • The pattern r"[+-]?\d+" matches both positive and negative integers (+42 and -17), as well as unsigned integers (100).

Python Regular Expressions (Regex) Cheatsheet

Cheatsheet August 03, 2024
python

match = re.search(r'\d+', 'The price is 100 dollars')
if match:
    print(match.group())  # Output: 100

match = re.match(r'\d+', '123 apples')
if match:
    print(match.group())  # Output: 123

match = re.fullmatch(r'\d+', '12345')
if match:
    print(match.group())  # Output: 12345
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

Validate Password Strength

Code January 26, 2024
javascript

No preview available for this content.