Skip to main content

最简单的正则表达式工具

功能描述

  • 无需会正则表达式即可快速上手使用

pip安装

pip install re_helper
1.提取所有图片地址
    from re_helper import ReHelper
    source_str = '<img src="http://www.sss.com/a.png" alt="111"/>\n' \
                 '<img src="/a.png" alt="111"/>'
    src_list = ReHelper.extract_all_image_src(source_str)
    print(src_list)
    src_list2 = ReHelper.extract_all_image_src(source_str, pre_url='http://www.sss.com')
    print(src_list2)
2.删除文本中的所有<![CDATA标签
    source_html = """
        // <![CDATA[ if (!window.location.search) { const pathname = window.location.pathname.split('/'); window.location.href = `/${pathname[1]}/${pathname[2]}?page=1&sort=price_discount,desc`; } // ]]> ผู้นำแห่งผลิตภัณฑ์เครื่องไฟฟ้าชั้นนำจากเนเธอแลนด์ที่มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่ช่วยทำให้ชีวิตประจำวันของผู้คนสะดวกสบายขึ้น ไม่ว่าจะเป็นผลิตภัณฑ์เครื่องไฟฟ้าในครัวเรือน ผลิตภัณฑ์ดูแลร่างกาย ผลิตภัณฑ์ดูแลแม่และเด็ก และอีกมากมาย ให้ชีวิตทุกวันของคุณมีความสุข และสะดวกสบายด้วยผลิตภัณฑ์เครื่องไฟฟ้า PHILIPS
        """
    print(ReHelper.delete_cdata_label(source_html))
3.删除文本中的换行和tab占位符
    print(ReHelper.delete_tab_and_br('123   456 9000\n \t 33\r\t222제조일자/유효기간:판매자에게 문의\n\t\t\t\t\t'))
4.删除文本中的所有html标签
    source_s = "云云小坊 隱形內衣BRA 超黏款上薄下厚布面隱形胸罩膚色) <font color=#FF00CC><b>*隱形胸罩屬衛生用品,使用過請勿退貨*</font><br> | 膚A"
    print(ReHelper.delete_html_tag(source_s))
5.提取文本中的百分数
    print(ReHelper.extract_percent('asdqqq 87.9%'))
6.根据正则提取字符串中第一个匹配的元素
    print(ReHelper.extract_one_by_pattern("<p>(.*?)</p>", "<p>111111111111</p>", exclude=['<p>', '</p>']))
7.匹配<script type="application/json"></script>中的元素
    sss = """
    <script type="application/json">{"number":123456}</script>
    """
    print(ReHelper.parse_application_json_script_data(sss))
8.匹配数值类型价格
    print(ReHelper.get_price('Price:$10.18 ($0.28 / Count)'))
更多用法文档

Metadata

Release files for re-helper 1.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for re-helper 1.2.4
File Size Uploaded Provenance Actions
re_helper-1.2.4.tar.gz 10.1 kB Without provenance Details for re_helper-1.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for re-helper 1.2.4
File Interpreter ABI Platform Actions
re_helper-1.2.4-py3-none-any.whl Python 3 none any Details for re_helper-1.2.4-py3-none-any.whl

Total release size: 19.9 kB

Release files / re_helper-1.2.4.tar.gz

Download URL re_helper-1.2.4.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5699be6a4eb56a1fa2818d07d70efd123805ce51d1c673ca7ed5aef94b1f3aea
BLAKE2b-256 checksum
How to use checksums
093b4701ff7c9d24dfdf0c03ee05b2a13f9c3d9bede0e81b885069f3d2636e9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

Release files / re_helper-1.2.4-py3-none-any.whl

Download URL re_helper-1.2.4-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f32bd3bcf4e212c205cb173e25b04ca5228f118a3ed0313b04c79e0c2ae8761f
BLAKE2b-256 checksum
How to use checksums
5f7fa7a56be2111c7f953d24771b0d8e8340d7f128ffa872de9022cd20e4d30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

Security for re-helper 1.2.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page