Skip to main content

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

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 hashes)

Uploaded Source

Built Distribution

rex_plus-0.1.4-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page