Skip to main content
https://travis-ci.org/dakrauth/strutil.svg?branch=master

Strutil

Simple helper functions for using strings and regular expressions (mostly) interchangeably.

Requirements

  • Python 3.4+

Module Contents

strutil.is_string(obj)

Check if obj is a string

strutil.is_regex(obj)

Check if obj is a regular expression

strutil.replace(text, old, new, count=None, strip=False)

Replace an old subset of text with new.

old type may be either a string or regular expression.

If strip, remove all leading/trailing whitespace.

If count, replace the specified number of occurence, otherwise replace all.

strutil.remove(text, what, count=None, strip=False)

Like replace, where new replacement is an empty string.

strutil.replace_each(text, items, count=None, strip=False)

Like replace, where each occurrence in items is a 2-tuple of (old, new) pair.

strutil.remove_each(text, items, count=None, strip=False)

Like remove, where each occurrence in items is what to remove.

strutil.contains(text, what)

Check if what occurs in text

strutil.find_first(data, what)

Search for what in the iterable data and return the index of the first match. Return None if no match found.

strutil.splitter(text, token=None, expected=2, default='', strip=False)

Split text by token into at least expected number of results.

When token is None, the default for Python str.split is used, which will split on all whitespace.

token may also be a regex.

If actual number of results is less than expected, pad with default.

If strip, than do just that to each result.

Release files for strutil 0.2.1

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

Source distribution (sdist)

Source distribution for strutil 0.2.1
File Size Uploaded
strutil-0.2.1.tar.gz 3.4 kB Details

Built distribution (wheel)

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

Total release size: 8.3 kB

Release files / strutil-0.2.1.tar.gz

Download URL strutil-0.2.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
60c162169bf6d5eba97ceea2a08442659ce9e9795129f136afd704e96e063bb0
BLAKE2b-256 checksum
How to use checksums
3798b3d93ac2352be16e61cf9ee00961f41cef3bfd5194e7c591be8414f3826a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / strutil-0.2.1-py3-none-any.whl

Download URL strutil-0.2.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c73102a4bd745c736068a88858e017d70c1598de5facd3963337566285b1756f
BLAKE2b-256 checksum
How to use checksums
33663e4b51c7a123809ac4fcd2afb677b19e5798502b6a85c36383d6454223a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.3

1 release file

0.1.1

1 release file

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