'Converts a list of patterns into a regex.
Args:
patterns: A list of single and double wildcarded path specifying patterns.
Returns:
A regular expression matching any of the paths in patterns matching
one of the files with the path in the subdirectory of the application
basepath. Ex. if we have and basepath (app_root) of "approot" and
patterns "foo" and "bar", this returns the compiled regular expression
of \'(^approot\/foo$|^approot\/bar$)\'.'

def _CreatePatternListRegex(self, patterns):

    regexed_patterns = [self._CreateFileNameRegex(pat) for pat in patterns]
    def _StripLeadingSlashes(pat):
        while pat.startswith('/'):
            pat = pat[1:]
        return pat
    regexed_patterns = [self._CreateFileNameRegex(_StripLeadingSlashes(pat)) for pat in patterns]
    app_root_regex = self._CreateFileNameRegex(self._UrlifyPath(self.app_root))
    regexed_patterns = [('^%s\\/%s$' % (app_root_regex, pattern_regex)) for pattern_regex in regexed_patterns]
    return re.compile(('(%s)' % '|'.join(regexed_patterns)))
