Skip to content

haohanxabo1/lrparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lr Parse

Easy To Get The Substrings

PyPI-version View on GitHub License: MIT

lrparse is a tiny, fast Python library written in C for extracting substrings between left and right delimiters.

Features

  • 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

Install

pip install lrparse

Usage

import 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'] 

Contributing

Contributions are welcome! 😊
Whether it's fixing a bug, improving performance, adding examples, or suggesting new features — any help is appreciated.

Shoutout

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 🙌