mgsub
A safe, multiple, simultaneous string substitution function
Why do I want this?
You have a string you want to make substitutions on. You want to make many different substitutions at the same time and you want them done in a safe way. For example, you want to shift each word in "hey, how are you?" to the left by replacing "hey" with "how", "how" with "are, etc. This is a lightweight, pure python function with no dependencies to avoid package bloat when being used.
Install it!
You need to have git installed
- Clone the repo to your loacl machine. Type this in a command promp/terminal
git clone https://github.com/bmewing/mgsub-python
- goto repo directory
cd mgsub-python
- install the module
python setup.py install
- You are all done!
Usage
Simply pass in a vector of strings to be modified, a vector of patterns to match and a vector of replacements. Then watch as they are safely, simultaneously replaced!
from mgsub import mgsub
mgsub(string, pattern=[], replacement=[], flags=0)
The pattern to match is supplied first and the replacement vector follows.
mgsub("hey, how are you?",["hey","how","are","you"],["how","are","you","hey"])
Matches and replacements can still be supplied as regex exressions. Flags from re can be set to modify how the regex works.
import re
mgsub("Dopazamine is not the same as Dopachloride and is still fake.",
[r'[Dd]opa(.*?mine)',"fake"], ["Meta\\1","real"], flags=re.I)
Metadata
Release files for mgsub 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mgsub-0.1.0.tar.gz | 3.2 kB | Without provenance | Details for mgsub-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mgsub-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mgsub-0.1.0-py3-none-any.whl |
Total release size: 7.7 kB
Release files / mgsub-0.1.0.tar.gz
| Download URL | mgsub-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
092fda9c18826df5b3b075a819f0f8debc7c52813150f4fc876ab67a0745d51a
|
|
BLAKE2b-256 checksum How to use checksums |
08b6790a95405dc13cd53ba86bbb4390a91bbf13566ab7819a691f83c195033f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.5.2
|
Release files / mgsub-0.1.0-py3-none-any.whl
| Download URL | mgsub-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a384cb77315ce01c8b4fa65dc6a4baff86d7b05cac83e8cd65957cf68427f85
|
|
BLAKE2b-256 checksum How to use checksums |
842945381b4b1e6fa52a129223b31314665ac333413ac3e0104ede11efe69d1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.5.2
|
Security for mgsub 0.1.0
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.