Get the context around an index location in a string
Project description
stringcontext
Simple Python library functions for getting the context around an index location in a string.
This library was designed to handle retrieving a given amount of context around, before, or after an index location in a string.
context_after: returns the string ofncharacters after the given index, or until the end of the string.context_before: returns the string ofncharacters before the given index, or until the beginning of the string.context: returns the full string of the context before, after, and including the character at index.
The code handles out of range issues on both ends of the string.
Based on the grep program's -C option switch
Usage
import stringcontext
string = "Hello World test"
index = 5 # the space char
c = stringcontext.context(string, index, 5)
# "Hello World"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stringcontext-1.0.0.tar.gz.
File metadata
- Download URL: stringcontext-1.0.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06848cacc641aa2f5f7747743f4338dbe9d88935f954de7e893dd1218325b6c0
|
|
| MD5 |
8c3fab580239d9dcf8ab43ee2d051f05
|
|
| BLAKE2b-256 |
4ce0ce4dab55adb7297954ee0d33bf3c4010989709a13413ff7bff90d455277b
|
File details
Details for the file stringcontext-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stringcontext-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
045d1fe435a01c050c4d8563f8cd60625bc4a4f1dfc357dec6001c7c840b71e4
|
|
| MD5 |
ff559302cc18fa0a9aa41bb701bfd55a
|
|
| BLAKE2b-256 |
e91bbdfb65f31014117f6a1140116e0e19ca3ce9413e8256c9ece3f5d3230f0e
|