Пример #1
0
def test__matches__identifies_from_compiled_expressions():

    match = matches(re.compile('a|bb*'))

    assert match('a')
    assert match('bbb')
    assert not match('c')
Пример #2
0
def test__matches__identifies_matching_expressions():

    match = matches('a|bb*')

    assert match('a')
    assert match('bbb')
    assert match('abb')
    assert not match('c')
Пример #3
0
def test__punctuation__matches_typical():

    match = matches(teeth.pattern.punctuation)

    assert match('.')
    assert match('?!')
    assert match('???')
    assert match('--')
    assert match('...')

    assert not match('ok')
    assert not match(' ')
Пример #4
0
 def the_letter_e(x):
     return matches('e')(x)
Пример #5
0
 def word_ends(x):
     return matches('[ \n!]+')(x)
Пример #6
0
 def sentence_ends(x):
     return matches('[.?!]')(x)