def times2(self, regex, lbr, min, comma, rbr): min = ''.join((ind.val() for ind in min)) repeat = Repeat(regex.val(), int(min)) return repeat return repeat
def times13(self, regex, lbr, num, rbr, question): repeat = Repeat(regex.val(), min=int(num.val()), max=int(num.val()), greedy=True) return repeat
def times12(self, regex, lbr, comma, max, rbr, question): repeat = Repeat(regex.val(), max=int(max.val()), greedy=True) return repeat
def times11(self, regex, lbr, min, comma, rbr, question): repeat = Repeat(regex.val(), int(min.val()), greedy=True) return repeat
def times3(self, regex, lbr, comma, max, rbr): max = ''.join((ind.val() for ind in max)) repeat = Repeat(regex.val(), max=int(max)) return repeat
def times1(self, regex, lbr, num, rbr): num = ''.join((ind.val() for ind in num)) num = int(num) repeat = Repeat(regex.val(), num, num) return repeat
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()
from crocs.regex import Pattern, Repeat, Group e = Pattern('a', Repeat('b'), Repeat(Group('cd'))) e.test() e.hits()