code: def construct_name_filter(pattern):
      
      if pattern is None:
          return False, lambda name: True
      if pattern.startswith('/') and pattern.endswith('/'):
          name_re = re.compile(pattern[1:-1])
          return False, lambda name: name_re.search(name) is not None
      return True, lambda name: name == pattern
docs: Return a function for filtering sensor names based on a pattern.
  
      Parameters
      ----------
      pattern : None or str
          If None, the returned function matches all names.
          If pattern starts and ends with '/' the text between the slashes
          is used as a regular expression to search the names.
          Otherwise the pattern must match the name of the sensor exactly.
  
      Returns
      -------
      exact : bool
          Return True if pattern is expected to match exactly. Used to
          determine whether having no matching sensors constitutes an error.
      filter_func : f(str) -> bool
          Function for determining whether a name matches the pattern.