def build_alpha_spans(alpha_spans_str, alpha_regexs):
 spans = []
 for elem in alpha_spans_str:
  if (elem in alpha_regexs):
   spans.append(re.compile(alpha_regexs[elem]))
  else:
   bucket = sorted([x for x in elem.lower() if x.isalnum()])
   if bucket:
    begin_index = ASCII_DIGITS.index(bucket[0])
    end_index = ASCII_DIGITS.index(bucket[(-1)])
   else:
    raise ui.UserError((u"invalid range defined for alpha bucket '%s': no alphanumeric character found" % elem))
   spans.append(re.compile(((('^[' + ASCII_DIGITS[begin_index:(end_index + 1)]) + ASCII_DIGITS[begin_index:(end_index + 1)].upper()) + ']')))
 return spans

def build_alpha_spans ( alpha_spans_str , alpha_regexs ) : spans = [ ] for elem in alpha_spans_str : if ( elem in alpha_regexs ) : spans . append ( re . compile ( alpha_regexs [ elem ] ) ) else : bucket = sorted ( [ x for x in elem . lower ( ) if x . isalnum ( ) ] ) if bucket : begin_index = ASCII_DIGITS . index ( bucket [ 0 ] ) end_index = ASCII_DIGITS . index ( bucket [ ( - 1 ) ] ) else : raise ui . UserError ( ( u"invalid range defined for alpha bucket '%s': no alphanumeric character found" % elem ) ) spans . append ( re . compile ( ( ( ( '^[' + ASCII_DIGITS [ begin_index : ( end_index + 1 ) ] ) + ASCII_DIGITS [ begin_index : ( end_index + 1 ) ] . upper ( ) ) + ']' ) ) ) return spans
extract alphanumerics from string and return sorted list of chars [from .