def get_quantifier(ch, input_iter):
 if (ch in '*?+'):
  try:
   (ch2, escaped) = input_iter.next()
  except StopIteration:
   ch2 = None
  if (ch2 == '?'):
   ch2 = None
  if (ch == '+'):
   return (1, ch2)
  return (0, ch2)
 quant = []
 while (ch != '}'):
  (ch, escaped) = input_iter.next()
  quant.append(ch)
 quant = quant[:(-1)]
 values = ''.join(quant).split(',')
 try:
  (ch, escaped) = input_iter.next()
 except StopIteration:
  ch = None
 if (ch == '?'):
  ch = None
 return (int(values[0]), ch)

def get_quantifier ( ch , input_iter ) : if ( ch in '*?+' ) : try : ( ch2 , escaped ) = input_iter . next ( ) except StopIteration : ch2 = None if ( ch2 == '?' ) : ch2 = None if ( ch == '+' ) : return ( 1 , ch2 ) return ( 0 , ch2 ) quant = [ ] while ( ch != '}' ) : ( ch , escaped ) = input_iter . next ( ) quant . append ( ch ) quant = quant [ : ( - 1 ) ] values = '' . join ( quant ) . split ( ',' ) try : ( ch , escaped ) = input_iter . next ( ) except StopIteration : ch = None if ( ch == '?' ) : ch = None return ( int ( values [ 0 ] ) , ch )
parse a quantifier from the input .