Return a regular expression based on first_line_re suitable for matching
    strings.
342165
def _first_line_re():
    
    if isinstance(first_line_re.pattern, str):
        return first_line_re

    # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.
    return re.compile(first_line_re.pattern.decode())
79373
def match(self, string):
        """"""
        if self.casesensitive:
            return self.pattern == os.path.normcase(string)
        else:
            return self.pattern.lower() == os.path.normcase(string).lower()
458047
def search(pattern, text):
    ''
    return re.compile(str(pattern)).search(str(text))
1271809
def _match(self, regex):
        """"""
        cregex = re.compile(regex)
        for line in self.content.splitlines():
            match = cregex.match(line)
            if match:
                return match
        raise Exception('No "{0}" line in {1}.cpp'.format(
            regex_to_error_msg(regex),
            self.name
        ))
872017
def match(self, pattern):
        """"""

        m = pattern.match(self._string, self._index)
        if m:
            self._index = m.end()
        return m
849632
def _pattern_match(self, item, pattern):
        """"""
        if pattern.endswith('*'):
            return item.startswith(pattern[:-1])
        else:
            return item == pattern
560304
def find_line_beginning(strings: Sequence[str],
                        linestart: Optional[str]) -> int:
    
    if linestart is None:  # match an empty line
        for i in range(len(strings)):
            if is_empty_string(strings[i]):
                return i
        return -1
    for i in range(len(strings)):
        if strings[i].find(linestart) == 0:
            return i
    return -1
1335326
def _construct_regex(cls, fmt):
        """"""
        return re.compile(fmt.format(**vars(cls)), flags=re.U)
209076
def match_regex_list(patterns, string):
    """"""

    for p in patterns:

        if re.findall(p, string):
            return True

    return False
350046
def match_regexp(self, value, q, strict=False):
        """"""
        value = stringify(value)
        mr = re.compile(q)
        if value is not None:
            if mr.match(value):
                return
        self.shout('%r not matching the regexp %r', strict, value, q)
943470
def next_line(self, require_prefix=True):
        
        if require_prefix:
            m = self.expect_re(r'(?m)[^\n]*?$\n?')
        else:
            m = self._expect_re(r'(?m)[^\n]*$\n?', self.pos)
        self.match = m
        if m:
            return m.group()
650981
def regexp(__string: str, __pattern: str, __repl: Union[Callable, str], *,
           count: int = 0, flags: int = 0) -> str:
    
    return re.sub(__pattern, __repl, __string, count, flags)
687546
def prep_regex(patterns):
    """"""

    flags = 0 if Config.options.case_sensitive else re.I

    return [re.compile(pattern, flags) for pattern in patterns]
1248623
def matching_lines(re)
      @lines.each_with_index.select{|text, linenum| re.match(text)}.map{
        |i| i[1]+1}
    end
1013735
def check(self, regex):
        
        return self.scan_full(regex, return_string=True, advance_pointer=False)
683966
def startswith(text, ignore_case=True):
        
        if ignore_case:
            compiled = re.compile(
                "^%s" % text.replace("\\", "\\\\"), re.IGNORECASE)
        else:  # pragma: no cover
            compiled = re.compile("^%s" % text.replace("\\", "\\\\"))

        return {"$regex": compiled}
958707
def _matchPattern(regExp, string):
        
        match = regExp.match(string)
        if match is not None and match.group(0):
            return match.group(0), (match.group(0), ) + match.groups()
        else:
            return None, None