title: Python print with integer string mix and group matching problem
body: <pre><code>import re
  import string
  line = &quot;F1,F2,F3,F6,R1,R3,R341,C1,C10,C2,FL1,FL5&quot;
  
  line_no_digits= re.findall(&quot;\D&quot;,line)#produce line with refernces F,F,F,F,R,R,R,C,C,C,FL,FL
  line_no_digits_string= ''.join(map(str,line_no_digits))
  #############################################################
  res = line_no_digits_string.split(&quot;,&quot;)
  alpha_char_unique=[]
  for i in res:                      #get unique reference prefix
      if i not in alpha_char_unique:
          alpha_char_unique.append(i)
  #############################################################
  line2 = line.split(&quot;,&quot;)
  preLine = &quot;&quot;
  result = &quot;&quot;
  for j in alpha_char_unique:
      p = re.compile(j)
      preLine = [s for s in line2 if p.match(s)]
      numbers_only = [int(re.search('\d+', l).group(0)) for l in preLine if re.search('\d+', l) is not None]#pull numbers for matches or prefix, not working correctly
      numbers_only.sort()#sort the numbers to work in code below
      #print(numbers_only)
      c = 0#counter
      result = &quot;&quot;#output result
      current = None
      run = False
      x = len(numbers_only)
      while c &lt; x:#number sorter
  
          if current == None:
              result += f'{numbers_only[c]}'
          elif numbers_only[c] - current == 1:
              run = True
              if c == len(numbers_only) - 1:
                  result += f'-{numbers_only[c]}'
          elif run:
              result += f'-{current},{numbers_only[c]}'
              run = False
          else:
              result += f',{numbers_only[c]}'
  
          current = numbers_only[c]
          c += 1
      print(result)
  </code></pre>
  <p>The result is
  1,1-3,5-6
  1,3,341
  1-2,10
  1,5
  I would like it to be
  F1-F3,F6
  R1,R3,R341
  C1-C2,C10
  FL1,FL5</p>
  <p>matching may not be the best for this.  I am looking for suggestions on how to make sure that F1-F3 and FL1,FL5 are not grouped together.  I am open to suggestions.</p>