Skip to main content

strsplit

A flexible string splitting utility for Python that allows splitting by different strategies and filtering the results using predicates. This package is inspired by the abseil StrSplit library.

PyPI version Supported Python versions Build License

Features

  • Split by a delimiter string (SplitByStr)
  • Split by fixed length chunks (SplitByLength)
  • Split by any character in a set (SplitByAnyChar)
  • Control maximum splits with maxsplit parameter (default -1 = no limit)
  • Filter out substrings via a predicate function in the main split function

Usage

from strsplit import split, SplitByStr, SplitByAnyChar, SplitByLength
# Split using a string delimiter
it = split(text="a,b,c", ",") # <=> it = split(text="a,b,c", splitter=SplitByStr(","))
print(list(it)) # --> ['a', 'b', 'c']

# Split by any chars
it = split(text="a,b;c-d", [",", ";", "-"]) # <=> it = split(text="a,b,c", splitter=SplitByAnChar(",;-"))
print(list(it)) # --> ['a', 'b', 'c', 'd']

# Split by length
it = split(text="abcdef", splitter=SplitByLength(2)) # <=> it = split(text="abcdef", 2)
print(list(it)) # --> ["ab", "cd", "ef"]

# Use a predicat to filter the result 
it = split(",a,,b,c,", ",", lambda x : len(x) > 0)
print(list(it)) # --> ['a', 'b', 'c']

# Limit the number of substr
# Every splitter accepts another parameter maxsplit to limit the number of splits
it = split(text="a,b,c,d", SplitByStr(delimiter=",", maxsplit=2))
print(list(it)) # --> ['a', 'b']

Metadata

Release files for strsplitter 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strsplitter 1.0.3
File Size Uploaded Provenance Actions
strsplitter-1.0.3.tar.gz 7.0 kB Without provenance Details for strsplitter-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strsplitter 1.0.3
File Interpreter ABI Platform Actions
strsplitter-1.0.3-py3-none-any.whl Python 3 none any Details for strsplitter-1.0.3-py3-none-any.whl

Total release size: 13.4 kB

Release files / strsplitter-1.0.3.tar.gz

Download URL strsplitter-1.0.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e8a6a714845e144be9c68ab7b57b7de4386b1c79cdc8f82da640ed0b03504373
BLAKE2b-256 checksum
How to use checksums
5d9772502ffd924be53e8d98862c7ef223e08ffb2963df2335d84a77877a3fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.3

Release files / strsplitter-1.0.3-py3-none-any.whl

Download URL strsplitter-1.0.3-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5773c967bc61c101ed2f36efd541199f27f81bda17ad67bba028ce2043f465b0
BLAKE2b-256 checksum
How to use checksums
7ac3d2070165842d089cce040cdc36b792a753974b38ff487c10d1d20527c6c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.3

Security for strsplitter 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page