Skip to main content

combine re compile

Project description

任意组合 re.compile

PyPI version License: MIT

兼容环境

Windows/Linux/MacOs


1 安装

pip 安装

$ pip install combine_re_compile

源码安装

 $ git clone https://github.com/landybird/combine_re_compile.git
 $ cd combine_re_compile
 $ python setup.py install

2 使用

DIGIT_PATTERN = re.compile(r"""
    (?P<my_digit_pattern>        # start named group
      \d+                        # 1 or more integers
    )                            # close named group
    """, re.VERBOSE)



CHAR_PATTERN = re.compile(r"""
    (?P<my_char_pattern>         # start named group
      [a-z]                      # a character
    )                            # close named group
    """, re.VERBOSE)


CHARS_PATTERN = re.compile(r"""
    (?P<my_char_pattern>         # start named group
      [a-z]+                     # a character
    )                            # close named group
    """, re.VERBOSE)


r = CombinationPattern(DIGIT_PATTERN, CHAR_PATTERN, new_pattren_name="my_new_pattern").get_new_pattern

s = "213213as2312"
print(r.search(s).group('my_new_pattern')) # 分组名称

>> 213213a

License

MIT ©landybird

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

combine_re_compile-0.0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

combine_re_compile-0.0.2-py3-none-any.whl (3.9 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