Socket
Book a DemoInstallSign in
Socket

regex-replacer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-replacer

Simple class for replace test with regex. Support scikit-learn transformer interface.

pipPyPI
Version
0.1.4
Maintainers
1

Regex Replacer

This is simple package for fast replace texts with regex. Support Rust regex syntax: https://docs.rs/regex/latest/regex/#syntax

Installation

pip install regex_replace --upgrade

Usage

from regex_replacer import RegexReplacerTransformer

transformer = RegexReplacerTransformer([
    (r'[0-9]+', " NUMBER "),
    (r"[a-z]+", " WORD ")
])
test_strings = [
    "this is a SIMPLE TEXT 12345 with number"
]
print(transformer.transform(test_strings))

# Output: [' WORD   WORD   WORD  SIMPLE TEXT  NUMBER   WORD   WORD ']

for multithread transform:

transformer = RegexReplacerTransformer([
        (r'[0-9]+', " NUMBER "),
        (r"[a-z]+", " WORD ")
    ], n_jobs=3)

to back to single thread:

transformer.to_single_thread()

FAQs

Did you know?

Socket

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.

Install

Related posts