
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
A safe, multiple, simultaneous string substitution function
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.
You need to have git installed
git clone https://github.com/bmewing/mgsub-python
cd mgsub-python
python setup.py install
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)
FAQs
A safe, multiple, simultaneous string substitution function
We found that mgsub demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.