def MakeTokenRegex(meta_left, meta_right):
    """Return a (compiled) regular expression for tokenization.

  Args:
    meta_left, meta_right: e.g. '{' and '}'

  - The regular expressions are memoized.
  - This function is public so the syntax highlighter can use it.
  """
    key = meta_left, meta_right
    if key not in _token_re_cache:
        # - Need () grouping for re.split
        # - The first character must be a non-space.  This allows us to ignore
        # literals like function() { return 1; } when
        # - There must be at least one (non-space) character inside {}
        _token_re_cache[key] = re.compile(
            r'(' +
            re.escape(meta_left) +
            r'\S.*?' +
            re.escape(meta_right) +
            r')')
    return _token_re_cache[key]