Skip to main content

strtoolz

Extra string search and manipulation functions for str, bytes & bytearray objects in Python.

  • find_all()
  • find_iter()
  • find_nth()
  • index_nth()
  • replace_counted()
  • replace_exactly()
  • replace_nth()

Usage

Finding

>>> import strtoolz
>>> strtoolz.find_all("The rain in Spain falls mainly on the plain", 'ain')
[5, 14, 25, 40]
>>> strtoolz.find_nth("The rain in Spain falls mainly on the plain", 'ain', n=2)
25

Replacing

>>> strtoolz.replace_counted('The rain in Spain falls mainly on the plain', 'ain', 'AIN')
('The rAIN in SpAIN falls mAINly on the plAIN', 4)
>>> strtoolz.replace_exactly('The rain in Spain falls mainly on the plain', 'ain', 'AIN', 10)
Traceback (most recent call last):
...
ValueError: Only 4 occurences could be replaced, required 10
>>> strtoolz.replace_nth('The rain in Spain falls mainly on the plain', 'ain', 'AIN', n=3)
'The rain in Spain falls mainly on the plAIN'

Installtion

uv pip install strtoolz

or

pip install strtoolz

Licence

MIT

See also

stdlib

re was inspiration for some of the functions in strtoolz, including strtoolz.find_all()/strtoolz.find_iter().

To find static strings with re your must escape any metachars

>>> pattern = re.compile(re.escape('an.'))
>>> [m.start() for m in pattern.finditer('A man. A plan. A canal. Panama!')]
[3, 11]

Combine re with itertools to recreate strtoolz.find_nth()

>>> pattern = re.compile(re.escape('an.'))
>>> matches = pattern.finditer('A man. A plan. A canal. Panama!')
>>> next(itertools.islice(matches, 1, None), -1).start()
11

Metadata

Release files for strtoolz 0.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 strtoolz 0.0.3
File Size Uploaded Provenance Actions
strtoolz-0.0.3.tar.gz 6.3 kB Without provenance Details for strtoolz-0.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 10.1 kB

Release files / strtoolz-0.0.3.tar.gz

Download URL strtoolz-0.0.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ff966bf82734d4bdf1c2b04e768e0e862c75eaa1f388fa670f566c7732a07909
BLAKE2b-256 checksum
How to use checksums
595569fced32a13b398197fbf50339505570010c20f1f6fadef6b782e4cb1198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / strtoolz-0.0.3-py3-none-any.whl

Download URL strtoolz-0.0.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3e0f68b33ba5290adc7d6888ed8de55ebc1e59c08d51444d5478fbd7477be77
BLAKE2b-256 checksum
How to use checksums
d2c7fe1ce7296ec6e6aad734d791ed2d30c570a7373fd096c28db5cc236619fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for strtoolz 0.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