Easy Regex
py_simple.easy_regex
extract_emails(text)
Returns a list of all email addresses found in the text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search for email addresses. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list | None
|
All email addresses found in the text. Empty list if none found. |
Example
from py_simple import extract_emails
result = extract_emails("Contact us at hello@example.com or support@test.org")
# -> ['hello@example.com', 'support@test.org']
import re
pattern = r'[a-zA-Z_.%+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]+'
result = re.findall(pattern, "Contact us at hello@example.com or support@test.org")
# -> ['hello@example.com', 'support@test.org']
extract_number_sequences(text)
Returns a list of number sequences found in the text, where numbers are joined by a separator such as -, _, : or . (e.g. dates, times, IP addresses, version numbers, or IDs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search for number sequences. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list | None
|
All number sequences found in the text. Empty list if none found. |
Example
from py_simple import extract_number_sequences
result = extract_number_sequences("Server 192.168.1.1 logged in at 14:32 on 04-08-2026")
# -> ['192.168.1.1', '14:32', '04-08-2026']
import re
pattern = r'[0-9]+(?:(?:-|_|:|\.)?[0-9]+)+'
result = re.findall(pattern, "Server 192.168.1.1 logged in at 14:32 on 04-08-2026")
# -> ['192.168.1.1', '14:32', '04-08-2026']
extract_numbers(text)
Returns a list of all standalone digit sequences found in the text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search for numbers. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list | None
|
All digit sequences found in the text. Empty list if none found. |
Example
from py_simple import extract_numbers
result = extract_numbers("I have 3 cats and 12 fish")
# -> ['3', '12']
import re
pattern = r'[0-9]+'
result = re.findall(pattern, "I have 3 cats and 12 fish")
# -> ['3', '12']
extract_urls(text)
Returns a list of all URLs found in the text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to search for URLs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list | None
|
All URLs found in the text. Empty list if none found. |
Example
from py_simple import extract_urls
result = extract_urls("Visit https://www.example.com or www.test.org today")
# -> ['https://www.example.com', 'www.test.org']
import re
pattern = (r'(?:https?://(?:www\.)?|www\.)[a-zA-Z0-9-]+\.
(?:(?:[a-zA-Z0-9-]+\.)*)?(?:(?:[a-zA-Z0-9-]+\\)*)?[a-zA-Z]{2,}
(?:\.[a-zA-Z]{2,})?(?:/\S*)?')
result = re.findall(pattern, "Visit https://www.example.com or www.test.org today")
# -> ['https://www.example.com', 'www.test.org']