Skip to main content

re tool easy for use

Project description

最简单的正则表达式工具

功能描述

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

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)'))
更多用法文档

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

re_helper-1.2.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

re_helper-1.2.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file re_helper-1.2.4.tar.gz.

File metadata

  • Download URL: re_helper-1.2.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for re_helper-1.2.4.tar.gz
Algorithm Hash digest
SHA256 5699be6a4eb56a1fa2818d07d70efd123805ce51d1c673ca7ed5aef94b1f3aea
MD5 9d51236ec436abc2445d18dd697b2561
BLAKE2b-256 093b4701ff7c9d24dfdf0c03ee05b2a13f9c3d9bede0e81b885069f3d2636e9a

See more details on using hashes here.

File details

Details for the file re_helper-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: re_helper-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for re_helper-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f32bd3bcf4e212c205cb173e25b04ca5228f118a3ed0313b04c79e0c2ae8761f
MD5 623cf3eca8431e736914077742c46cf3
BLAKE2b-256 5f7fa7a56be2111c7f953d24771b0d8e8340d7f128ffa872de9022cd20e4d30b

See more details on using hashes here.

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