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 🙌