You can match and replace strings with regular expressions.
Project description
📦 rex-plus (for humans)
Plus version of re
Installation
pip install -i https://mirrors.aliyun.com/pypi/simple/ --extra-index-url https://pypi.org/simple/ rex-plus
Example
import rex_plus
# 正则替换
# Partial replacement according to regular expression
rex_plus.sub('(限行)灯', ['线型'], '卧室有一盏限行灯')
# output: '卧室有一盏线型灯'
rex_plus.sub('(我是).*(限行)灯', ['卧室', '线型'], '卧室有一盏限行灯')
# output: 卧室有一盏线型灯
rex_plus.sub('(?:卧室)的(限行)灯', ['线型'], '卧室的限行灯')
# output: 卧室的线型灯
rex_plus.sub('(?:(我是)的)(限行)灯', ['卧室', '线型'], '卧室的限行灯')
# output: 卧室的线型灯
# 查询所有匹配项,并返回对应的index和text
rex_plus.search_all(r"\d", "__a1bb2ccc3")
# output: [<rex_plus.Match object; span=(3, 4), text='1'>, <rex_plus.Match object; span=(6, 7), text='2'>, <rex_plus.Match object; span=(10, 11), text='3'>]
To Do
- Be the best version of you.
More Resources
- rex-plus on github.com
- Official Python Packaging User Guide
- The Hitchhiker's Guide to Packaging
- Cookiecutter template for a Python package
License
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rex-plus-0.1.4.tar.gz
(5.4 kB
view details)
Built Distribution
File details
Details for the file rex-plus-0.1.4.tar.gz
.
File metadata
- Download URL: rex-plus-0.1.4.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62eddb7dd775ca0abf8a68e8d77e539c3a6a1bbc78280977e3671a07da1fb5b |
|
MD5 | 49222d64fde8f244392e55530a435c4a |
|
BLAKE2b-256 | b70a8f3fbd9964f372a04c208f4f6f195cb67094f49576c8394c53a48376a6c0 |
File details
Details for the file rex_plus-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: rex_plus-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 582cc5cc8070f791b3c2509842a5e947e6ef4f66e08dc5e7f50538c4ff8ef697 |
|
MD5 | c8771cdb95dbc04229eb1f4af1603a5a |
|
BLAKE2b-256 | 0e6922d8890f8876d2a04f28b6fa8a87fcf0598f0dd536ad379cb4b0c309029c |