Beispiel #1
0
from crocs.regex import Pattern, Group, X

e = Pattern('a', Group('b', X()))
e.test()
e.hits()
Beispiel #2
0
from crocs.regex import Seq, Include, Repeat, Pattern, NamedGroup, Include

# First we define how our Patterns look like.
name_letters = Include(Seq('a', 'z'))

# The regex {n,m} repeatition. The name should contains more
# than 0 chars.
name = Repeat(name_letters, 1)

# Create a named group to make it available after matching.
name = NamedGroup('name', name)

# The hostname part looks like the name except
# it starts with 'python' in the beginning,
hostname = Repeat(name_letters, 1)
hostname = NamedGroup('hostname', 'python', hostname)

# The Pattern class joins the sub patterns it forms a single one.
mail = Pattern(name, '@', hostname, '.', 'br')
mail.test()
mail.hits()
Beispiel #3
0
from crocs.regex import Pattern, Group, X, Include, ZeroOrMore, Repeat, Seq

e0 = Group('a')
e1 = ZeroOrMore(e0)
e2 = Pattern(e0, 'b', e0)
print(e2.mkregex())
e2.test()
Beispiel #4
0
from crocs.regex import Pattern, NamedGroup, X

e0 = NamedGroup('beta', 'X', X(), 'B')
e1 = Pattern('um', e0, 'dois', e0, 'tres', e0)

e1.test()
e1.hits()