lrparse is a tiny, fast Python library written in C for extracting substrings between left and right delimiters.
-
lr()β fetches the first occurrence between a left and right delimiter. -
lrr()β fetches all non-overlapping occurrences between delimiters. -
Returns results as native Python lists of strings for easy integration
pip install lrparseimport lrparse
# lr() β first match between delimiters
print(lrparse.lr("pre[mid]post", "[", "]"))
# Output: ['mid']
# lrr() β all matches between delimiters
print(lrparse.lrr("<a><b>c", "<", ">"))
# Output: ['a', 'b']
# If delimiters don't exist β returns an empty list
print(lrparse.lr("hello world", "{", "}"))
# Output: []
# If both delimiters are empty β returns the whole string
print(lrparse.lr("abc", "", ""))
# Output: ['abc'] Contributions are welcome! π
Whether it's fixing a bug, improving performance, adding examples, or suggesting new features β any help is appreciated.
The idea behind this project came from the Parse Block in OpenBullet - a powerful tool for automating and analyzing HTTP requests. I always liked how fast and straightforward it handled text extraction, so I wanted to create a tiny standalone version for Python.
Big respect to the OpenBullet devs and community π