• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python re_test_patterns.test_patterns函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中re_test_patterns.test_patterns函数的典型用法代码示例。如果您正苦于以下问题:Python test_patterns函数的具体用法?Python test_patterns怎么用?Python test_patterns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test_patterns函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_patterns

# -*- coding: utf-8 -*-

"""贪婪匹配"""
from re_test_patterns import test_patterns

test_patterns('abbaaabbbbaaaaa',
              ['ab*',
               'ab+',
               'ab?',
               'ab{3}',
               'ab{2,3}'])
开发者ID:rApeNB,项目名称:PyMOTW,代码行数:11,代码来源:re_repetition.py


示例2: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Escaping escape codes
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns(r'\d+ \D+ \s+ \S+ \w+ \W+',
              [ r'\\d\+',
                r'\\D\+',
                r'\\s\+',
                r'\\S\+',
                r'\\w\+',
                r'\\W\+',
                ])
开发者ID:deweing,项目名称:PyMOTW,代码行数:19,代码来源:re_escape_escapes.py


示例3: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Regular expression grouping
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns(
    'abbaaabbbbaaaaa',
    [ ('a(ab)',    'a followed by literal ab'),
      ('a(a*b*)',  'a followed by 0-n a and 0-n b'),
      ('a(ab)*',   'a followed by 0-n ab'),
      ('a(ab)+',   'a followed by 1-n ab'),
      ])
开发者ID:abner0908,项目名称:pythonProject,代码行数:18,代码来源:re_groups.py


示例4: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns(
    "abbaaabbbbaaaaa",
    [
        "ab*",  # a seguito da zero o più b
        "ab+",  # a seguito da uno o più b
        "ab?",  # a seguito da zero od una b
        "ab{3}",  # a seguito da tre b
        "ab{2,3}",  # a seguito da due a tre b
    ],
)
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:15,代码来源:re_repetitions.py


示例5: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns('abbaaabbbbaaaaa',
              [ 'a(ab)',    # 'a' seguito da 'ab' letterale
                'a(a*b*)',  # 'a' seguito da 0-n 'a' e 0-n 'b'
                'a(ab)*',   # 'a' seguito da 0-n 'ab'
                'a(ab)+',   # 'a' seguito da 1-n 'ab'
                ])
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:11,代码来源:re_groups.py


示例6: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Escape codes
"""
# end_pymotw_header

from re_test_patterns import test_patterns

test_patterns(
    "A prime #1 example!",
    [
        (r"\d+", "sequence of digits"),
        (r"\D+", "sequence of nondigits"),
        (r"\s+", "sequence of whitespace"),
        (r"\S+", "sequence of nonwhitespace"),
        (r"\w+", "alphanumeric characters"),
        (r"\W+", "nonalphanumeric"),
    ],
)
开发者ID:reingart,项目名称:pymotw,代码行数:22,代码来源:re_escape_codes.py


示例7: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns('abbaaabbbbaaaaa',
              [ 'a.',   # a seguito da qualsiasi carattere
                'b.',   # b seguito da qualsiasi carattere
                'a.*b', # a seguito da qualunque cosa, che finisca per b
                'a.*?b', # a seguito da qualunque cosa, che finisca per b
                ])
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:11,代码来源:re_charset_dot.py


示例8: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Escape codes
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns('This is a prime #1 example!',
              [ r'\d+', # sequence of digits
                r'\D+', # sequence of non-digits
                r'\s+', # sequence of whitespace
                r'\S+', # sequence of non-whitespace
                r'\w+', # alphanumeric characters
                r'\W+', # non-alphanumeric
                ])
开发者ID:deweing,项目名称:PyMOTW,代码行数:19,代码来源:re_escape_codes.py


示例9: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Repetition of patterns
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns(
    'This is some text -- with punctuation.',
    [ ('[^-. ]+',  'sequences without -, ., or space'),
      ])
开发者ID:abner0908,项目名称:pythonProject,代码行数:15,代码来源:re_charset_exclude.py


示例10: test_patterns

# re_anchoring.py

from re_test_patterns import test_patterns

test_patterns(
    'Trova in parte di testo -- con punteggiatura.',
    [(r'^\w+', 'parola ad inizio stringa'),
     (r'\A\w+', 'parola ad inizio stringa'),
     (r'\w+\S*$', 'parola verso la fine della stringa, senza punteggiatura'),
     (r'\w+\S*\Z', 'parola verso la fine della stringa, senza punteggiatura'),
     (r'\w*t\w*', 'parola che contiene t'),
     (r'\bt\w+', 't ad inizio della parola'),
     (r'\w+t\b', 't alla fine della parola'),
     (r'\Bt\B', 't, non all\'inizio o fine della parola')],
)
开发者ID:robertopauletto,项目名称:PyMOTW-it_3.0,代码行数:15,代码来源:re_anchoring.py


示例11: test_patterns

# re_repetition_non_greedy.py

from re_test_patterns import test_patterns

test_patterns(
    'abbaabbba',
    [('ab*?', 'a seguito da zero o più b'),
     ('ab+?', 'a seguito da one o più b'),
     ('ab??', 'a seguito da zero od una b'),
     ('ab{3}?', 'a seguito da tre b'),
     ('ab{2,3}?', 'a seguito da due fino a tre b')],
)
开发者ID:robertopauletto,项目名称:PyMOTW-it_3.0,代码行数:12,代码来源:re_repetition_non_greedy.py


示例12: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns('Questa porzione di testo -- con punteggiatura.',
              [ '[a-z]+',      # sequenza di lettere minuscole
                '[A-Z]+',      # sequenza di lettere maiuscole
                '[a-zA-Z]+',   # sequenza di lettere maiuscole o minuscole
                '[A-Z][a-z]+', # una lettera maiuscola seguita da lettere  minuscole
                ])
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:11,代码来源:re_charset_ranges.py


示例13: test_patterns

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Repetition of patterns
"""

from re_test_patterns import test_patterns

test_patterns(
    'abbaabbba',
    [ ('[ab]',    'either a or b'),
      ('a[ab]+',  'a followed by 1 or more a or b'),
      ('a[ab]+?', 'a followed by 1 or more a or b, not greedy'),
    ]
)
开发者ID:zxremail,项目名称:Python.Standard.Library.By.Example,代码行数:15,代码来源:re_charset.py


示例14: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns('abbaaabbbbaaaaa',
              [ '[ab]',    # sia a che b
                'a[ab]+',  # a seguito da uno o più a oppure b
                'a[ab]+?', # a seguito da uno o più a oppure b, non greedy
                ])
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:10,代码来源:re_charset.py


示例15: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Repetition of patterns
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns(
    'This is some text -- with punctuation.',
    [ ('[a-z]+', 'sequences of lowercase letters'),
      ('[A-Z]+', 'sequences of uppercase letters'),
      ('[a-zA-Z]+', 'sequences of lowercase or uppercase letters'),
      ('[A-Z][a-z]+', 'one uppercase followed by lowercase'),
      ])
开发者ID:abner0908,项目名称:pythonProject,代码行数:18,代码来源:re_charset_ranges.py


示例16: test_patterns

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from re_test_patterns import test_patterns

test_patterns(
    'abbaabbba',
    [('ab*?', 'a followed by zero or more b'),
     ('ab+?', 'a followed by one or more b'),
     ('ab??', 'a followed by zero or one b'),
     ('ab{3}?', 'a followed by three b'),
     ('ab{2,3}?', 'a followed by two to three b')],
)

开发者ID:kai0200,项目名称:PythonST,代码行数:13,代码来源:re_repetition_non_greedy.py


示例17: test_patterns

# -*- coding: utf-8 -*-

from re_test_patterns import test_patterns

test_patterns('This is a prime #1 example!',
              [r'\d+',
               r'\D+',
               r'\s+',
               r'\S+',
               r'\w+',
               r'\W+'])
开发者ID:rApeNB,项目名称:PyMOTW,代码行数:11,代码来源:re_escape_codes.py


示例18: test_patterns

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from re_test_patterns import test_patterns

test_patterns('This is a prime #1 example!',
              [ r'\d+', # sequenza di cifre
                r'\D+', # sequenza di non-cifre
                r'\s+', # sequenza di whitespace
                r'\S+', # sequenza di non-whitespace
                r'\w+', # caratteri alfanumerici
                r'\W+', # non-alfanumerici
                ])
开发者ID:robertopauletto,项目名称:PyMOTW-it_2.0,代码行数:13,代码来源:re_escape_codes.py


示例19: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Anchoring the search
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns('This is some text -- with punctuation.',
              [ r'^\w+',     # word at start of string
                r'\A\w+',    # word at start of string
                r'\w+\S*$',  # word at end of string, with optional punctuation
                r'\w+\S*\Z', # word at end of string, with optional punctuation
                r'\w*t\w*',  # word containing 't'
                r'\bt\w+',   # 't' at start of word
                r'\w+t\b',   # 't' at end of word
                r'\Bt\B',    # 't', not start or end of word
                ])
开发者ID:deweing,项目名称:PyMOTW,代码行数:21,代码来源:re_anchoring.py


示例20: Copyright

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Repetition of patterns
"""
#end_pymotw_header

from re_test_patterns import test_patterns

test_patterns('This is some text -- with punctuation.',
              [ '[a-z]+',      # sequences of lower case letters
                '[A-Z]+',      # sequences of upper case letters
                '[a-zA-Z]+',   # sequences of lower or upper case letters
                '[A-Z][a-z]+', # one upper case letter followed by lower case letters
                ])
开发者ID:deweing,项目名称:PyMOTW,代码行数:17,代码来源:re_charset_ranges.py



注:本文中的re_test_patterns.test_patterns函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python readmnist.read函数代码示例发布时间:2022-05-26
下一篇:
Python ffi.dlopen函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap