<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def grep(self, regex):
 """Scans the student files for text patterns. Args: regex (str):
 Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory. """

        matches = []
        logger.debug("Searching student files for '{0}'".format(regex))
        for fname in self.student_files:
            if os.path.isfile(self.working_dir + fname):
                for line in open(self.working_dir + fname, 'br'):
                    if re.search(regex.encode(), line):
                        logger.debug("{0} contains '{1}'".format(fname, regex))
                        matches.append(fname)
        return matches