Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A minimal Python library powered by Rust and PyO3 for generating regular expressions using natural language chainable functions.
This project provides a Python library that simplifies the creation of regular expressions by using a natural language syntax. It leverages Rust's performance and safety, with PyO3 bridging Rust and Python, to deliver an ultra-minimal runtime with zero dependencies.
re
module and other regex engines.Install the library using pip:
pip install rgxx
Here's how you can use the library to create a regular expression for matching dates in the YYYY-MM-DD
format:
python
Copy code
from rgxx import digit, exactly, any_of, RegExp
# Define the components of the date pattern
year = digit().times(4).grouped_as('year')
month = any_of(
exactly('0') & digit(),
exactly('10'), exactly('11'),
exactly('12')
).grouped_as('month')
day = any_of(
exactly('0') & digit(),
exactly('1') & digit(),
exactly('2') & digit(),
exactly('30'), exactly('31')
).grouped_as('day')
# Combine the components into a single RegExp object
date_pattern = RegExp(year, exactly('-'), month, exactly('-'), day)
print(date_pattern.compile())
Output:
`(?P<year>(\d){4})\-(?P<month>((0)\d|10|11|12))\-(?P<day>((0)\d|(1)\d|(2)\d|30|31))`
Example Usage with Python's **re**
Module:
import re
# Compile the generated regular expression
date_regex = re.compile(date_pattern.compile())
# Match a date string
match = date_regex.match('2023-10-05')
if match:
print(match.group('year')) # Output: 2023
print(match.group('month')) # Output: 10
print(match.group('day')) # Output: 05
**digit()**
: Matches any single digit (\d
).**exactly(s)**
: Matches the exact string s
, escaping special regex characters.**any_of(*patterns)**
: Matches any one of the provided patterns.**.times(n)**
: Repeats the pattern exactly n
times.**.grouped_as(name)**
: Names the capture group as name
.**.and(other)**
or **&**
: Concatenates the current pattern with another.Contributions are welcome! Please follow these steps:
This project is licensed under the MIT License.
Feel free to customize this bio further to suit your project's specific details or to add more sections such as acknowledgments, FAQs, or a roadmap.
FAQs
Unknown package
We found that rgxx 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.