Skip to main content

Left/right substring extraction

Project description

lrparse

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

It provides two functions:

  • lr() – returns the first substring between delimiters.
  • lrr() – returns all substrings between delimiters.

Installation

pip install lrparse

Usage

import lrparse

# lr() → first match between delimiters
print(lrparse.lr("pre[mid]post", "[", "]"))
# ['mid']

# lrr() → all matches between delimiters
print(lrparse.lrr("<a><b>c", "<", ">"))
# ['a', 'b']

# If delimiters don't exist, you get an empty list
print(lrparse.lr("hello world", "{", "}"))
# []

# If both delimiters are empty, the whole string is returned
print(lrparse.lr("abc", "", ""))
# ['abc']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lrparse-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file lrparse-0.1.0.tar.gz.

File metadata

  • Download URL: lrparse-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lrparse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 457edbd11e1c4e05cda3fea2f17ec46958ca4e15f5b22606a0595d8f280382d3
MD5 6cc6189432e2111bfcbdd74c0afdb03a
BLAKE2b-256 3da2cb03b04808e08ae2964cac4cad21806624bc0eeb2c8c2c1fa19627d67e4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page