code: def looking_at_escape(s, state):
      """Return # of characters in an escape
  
      s - string to look at
      state - the current search state
  
      returns either None or the # of characters in the escape
      """
      if s[0] != "\\":
          return
      if len(s) < 2:
          raise ValueError("Unterminated escape sequence")
      if s[:2] in HARDCODE_ESCAPES:
          return 2
      if state.in_brackets:
          # within brackets, only octal supported
          if s[1] in OCTAL_DIGITS:
              for i in range(2, min(4, len(s))):
                  if s[i] != OCTAL_DIGITS:
                      return i
          if s[1] in DECIMAL_DIGITS:
              raise ValueError(
                  "Numeric escapes within brackets must be octal values: e.g., [\\21] for ^Q"
              )
      elif s[1] == 0:
          for i in range(2, min(4, len(s))):
              if s[i] != OCTAL_DIGITS:
                  return i
      elif s[1] in DECIMAL_DIGITS:
          # A group number
          if len(s) > 2 and s[2] in DECIMAL_DIGITS:
              group_number = int(s[1:3])
              length = 2
          else:
              group_number = int(s[1])
              length = 1
          if group_number > state.group_count:
              raise ValueError(
                  "Only %d groups at this point" % state.group_count
              )
          return length
      if s[1] == "x":
          if s[2] in HEXIDECIMAL_DIGITS and s[3] in HEXIDECIMAL_DIGITS:
              return 4
          raise ValueError(
              "Hexidecimal escapes are two digits long: eg. \\x1F"
          )
      # The escape is needless, but harmless
      return 2
  
imports: import re
  import wx
  import wx.stc
label_desc: Use image node_id 2 for calling a global function with example usage: looking_at_escape(s, state) and returns: int, int, int, length, i, i