当前位置: 首页>>代码示例>>Python>>正文


Python re_test_patterns.test_patterns函数代码示例

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


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


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