
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Regexa is a comprehensive Python library that simplifies working with regular expressions for common text processing tasks. It provides an easy-to-use interface for validations, extractions, and text processing operations.
pip install regexa
from regexa import Regexa
rx = Regexa()
email = "john.doe@example.com"
print(f"Is email valid? {rx.match_email(email)}")
# Result: Is email valid? True
# Comment: The email is valid as it follows the standard email format
password = "MyStr0ng#Pass"
strength = rx.validate_password_strength(password)
print(f"Password strength: {strength['strength']}")
print(f"Password feedback: {strength['feedback']}")
# Result:
# Password strength: Excellent
# Password feedback: ['Password length sufficient', 'Has uppercase letters', 'Has lowercase letters', 'Has numbers', 'Has special characters']
# Comment: The password is excellent because it meets all criteria: length, uppercase, lowercase, numbers, and special characters
text = """
Contact me at john.doe@example.com or call +6281234567890
Visit our website: https://example.com
Follow us @company #tech #python
Meeting on 25/12/2023 and 2023-12-31
Credit card: 4111111111111111
"""
extracted = rx.extract_all(text)
print("\nExtracted data:")
for key, value in extracted.items():
print(f"{key}: {value}")
# Result:
# emails: ['john.doe@example.com']
# phones: ['+6281234567890']
# urls: ['https://example.com']
# hashtags: ['#tech', '#python']
# mentions: ['@company']
# numbers: ['6281234567890', '25', '12', '2023', '2023', '12', '31']
# words: ['Contact', 'me', 'at', 'john', 'doe', 'example', 'com', ...]
# Comment: Successfully extracted all different types of data from the text
dates = rx.extract_dates(text)
print("\nFound dates:")
for date in dates:
print(f"Date: {date['date']} (Format: {date['format']})")
# Result:
# Date: 25/12/2023 (Format: dd/mm/yyyy)
# Date: 2023-12-31 (Format: yyyy-mm-dd)
# Comment: Detected dates in different formats
url = "https://example.com"
print(f"\nIs URL valid? {rx.match_url(url)}")
# Result: Is URL valid? True
# Comment: URL is valid as it contains the correct protocol and domain format
card_number = "4111111111111111"
card_validation = rx.validate_credit_card(card_number)
print(f"\nCredit card validation: {card_validation}")
# Result: Credit card validation: {'is_valid': True, 'card_type': 'visa', 'number': '4111111111111111'}
# Comment: Detected as a valid Visa card number
cleaned_text = rx.clean_text("Hello, World! @#$%")
print(f"\nCleaned text: {cleaned_text}")
# Result: Cleaned text: Hello World
# Comment: Removed all special characters, leaving only alphanumeric characters and spaces
ip = "192.168.1.1"
ip_validation = rx.validate_ip(ip)
print(f"\nIP validation: {ip_validation}")
# Result: IP validation: {'is_valid': True, 'type': 'IPv4', 'private': True}
# Comment: Valid IPv4 address identified as a private IP address
rx.match_email(text: str) -> bool
Validates if a string is a properly formatted email address.
rx.match_phone_id(text: str) -> bool
Validates Indonesian phone numbers.
rx.match_url(text: str) -> bool
Checks if a string is a valid URL with HTTP/HTTPS protocol.
rx.validate_password_strength(password: str) -> Dict[str, Any]
Validates password strength and provides detailed feedback:
rx.extract_all(text: str) -> Dict[str, List[str]]
Extracts various elements from text:
rx.clean_text(text: str, remove_spaces: bool = False) -> str
Cleans text by removing special characters. Optional space removal.
rx.extract_dates(text: str) -> List[Dict[str, Any]]
Extracts dates in various formats:
rx.extract_filename(path: str) -> Dict[str, str]
Extracts components from file paths:
rx.validate_ip(ip: str) -> Dict[str, Any]
Validates IPv4 and IPv6 addresses and provides:
rx.count_matches(text: str, pattern: str) -> Dict[str, Any]
Counts pattern matches in text and provides:
rx.validate_credit_card(number: str) -> Dict[str, Any]
Validates credit card numbers and identifies card type:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A modern, full-featured regex library for Python
We found that regexa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.