code: def institute_num_pattern_to_regex(pattern):
      
      simple_replacements = [
          ('9', r'\d'),
          ('w+', r'\w+'),
          ('a', r'[A-Za-z]'),
          ('v', r'[Vv]'),
          ('mm', r'(0[1-9]|1[0-2])'),
          ('yyyy', r'[12]\d{3}'),
          ('yy', r'\d\d'),
          ('s', r'\s*'),
          (r'/', r'\/')]
  
      # now loop through and carry out the simple replacements:
      for repl in simple_replacements:
          pattern = pattern.replace(repl[0], repl[1])
  
      # now replace a couple of regexp-like paterns:
      # quoted string with non-quoted version ("hello" with hello);
      # Replace / [abcd ]/ with /( [abcd])?/ :
      pattern = re_extract_quoted_text[0].sub(re_extract_quoted_text[1],
                                              pattern)
      pattern = re_extract_char_class[0].sub(re_extract_char_class[1],
                                             pattern)
  
      # the pattern has been transformed
      return pattern
docs: Given a numeration pattern from the institutes preprint report
         numbers KB, convert it to turn it into a regexp string for
         recognising such patterns in a reference line.
         Change:
             \     -> \\
             9     -> \d
             a     -> [A-Za-z]
             v     -> [Vv]  # Tony for arXiv vN
             mm    -> (0[1-9]|1[0-2])
             yy    -> \d{2}
             yyyy  -> [12]\d{3}
             /     -> \/
             s     -> \s*
         @param pattern: (string) a user-defined preprint reference numeration
          pattern.
         @return: (string) the regexp for recognising the pattern.