Tries to match the text with the given pattern and returns the value of matching group
511695
def regex_group(ctx, text, pattern, group_num):
    
    text = conversions.to_string(text, ctx)
    pattern = conversions.to_string(pattern, ctx)
    group_num = conversions.to_integer(group_num, ctx)

    expression = regex.compile(pattern, regex.UNICODE | regex.IGNORECASE | regex.MULTILINE | regex.V0)
    match = expression.search(text)

    if not match:
        return ""

    if group_num < 0 or group_num > len(match.groups()):
        raise ValueError("No such matching group %d" % group_num)

    return match.group(group_num)
218646
private boolean matchPostagRegexp(AnalyzedTokenReadings aToken, Pattern pattern) {
    for (AnalyzedToken analyzedToken : aToken) {
      String posTag = analyzedToken.getPOSTag();
      if (posTag == null) {
        posTag = "UNKNOWN";
      }
      final Matcher m = pattern.matcher(posTag);
      if (m.matches()) {
        return true;
      }
    }
    return false;
  }
25327
def from_text(text):
    """"""

    value = _by_text.get(text.upper())
    if value is None:
        match = _unknown_type_pattern.match(text)
        if match == None:
            raise UnknownRdatatype
        value = int(match.group(1))
        if value < 0 or value > 65535:
            raise ValueError("type must be between >= 0 and <= 65535")
    return value
425509
def search(self, pattern):
        
        for node in self.nodes.values():
            match, following = pattern.match(self, node)
            if match:
                return match, following
        return [], None
1038630
def re_match(self, pattern, haystack, **kwargs):
        
        try:
            return re.match(pattern, haystack.decode('utf8'), **kwargs)

        except Exception as e:
            logger.debug('re.match exception: %s' % e)
            self.trace_logger.log(e)
219855
def match(pattern, name):
    # type: (Text, Text) -> bool
    
    try:
        re_pat = _PATTERN_CACHE[(pattern, True)]
    except KeyError:
        res = "(?ms)" + _translate(pattern) + r'\Z'
        _PATTERN_CACHE[(pattern, True)] = re_pat = re.compile(res)
    return re_pat.match(name) is not None
820664
private function matchesPattern($pattern) {
        $regexEncoding = mb_regex_encoding();
        mb_regex_encoding($this->encoding);

        $match = mb_ereg_match($pattern, $this->str);
        mb_regex_encoding($regexEncoding);

        return $match;
    }
878166
private static boolean check(String data, Pattern pattern) {
        if (StringUtils.isEmpty(data)) {
            return false;
        }
        Matcher matcher = pattern.matcher(data);
        return matcher.matches();
    }
648503
public static BooleanBinding matches(final ObservableValue<String> text, final String pattern) {
		return Bindings.createBooleanBinding(() -> {
			final String textToVerify = text.getValue();
			return textToVerify != null && textToVerify.matches(pattern);
		}, 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
        ))
1152819
protected static boolean matches( String text , String pattern , boolean ignoreCase )
    {
        if (text == null)
            return false;
        if (pattern.length() == 0)
            return text.length() == 0;
        
        int textPos = 0;
        boolean startWithAny = false;
        StringTokenizer st = new StringTokenizer(pattern,"*?",true);
        while (st.hasMoreTokens())
        {
            String subPattern = st.nextToken();
            
            if (subPattern.equals("*"))
            {
                startWithAny = true;
            }
            else
            if (subPattern.equals("?"))
            {
                if (textPos < text.length())
                    textPos++;
                else
                    return false;
            }
            else
            {
                if (startWithAny)
                {
                    textPos = indexOf(text,subPattern,textPos,ignoreCase);
                    if (textPos == -1) return false;
                    startWithAny = false;
                }
                else
                {
                    if (!startsWith(text,subPattern,textPos,ignoreCase))
                        return false;
                }
                textPos += subPattern.length();
            }
        }
        
        // Remaining text
        if (textPos < text.length())
            if (!startWithAny)
                return false;
        
        return true;
    }
783562
def fullmatch(pattern, string, flags=0):
    """"""
    # Build a version of the pattern with a non-capturing group around it.
    # This is needed to get m.end() to correctly report the size of the
    # matched expression (as per the final doctest above).
    grouped_pattern = re.compile("^(?:%s)$" % pattern.pattern, pattern.flags)
    m = grouped_pattern.match(string)
    if m and m.end() < len(string):
        # Incomplete match (which should never happen because of the $ at the
        # end of the regexp), treat as failure.
        m = None  # pragma no cover
    return m
1224727
def matches(self, txt: str) -> bool:
        
        # rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')
        if r'\\u' in self.pattern_re.pattern:
            txt = txt.encode('utf-8').decode('unicode-escape')
        match = self.pattern_re.match(txt)
        return match is not None and match.end() == len(txt)
902131
public CharSequence matchesPattern(final CharSequence input, final String pattern, final String message) {
        if (!Pattern.matches(pattern, input)) {
            fail(message);
        }
        return input;
    }
19279
def regex_search(txt, rgx, ignorecase=False, multiline=False):
    '''
    
    '''
    flag = 0
    if ignorecase:
        flag |= re.I
    if multiline:
        flag |= re.M
    obj = re.search(rgx, txt, flag)
    if not obj:
        return
    return obj.groups()
251159
def _is_pattern_match(re_pattern, s):
    """"""
    match = re.match(re_pattern, s, re.I)
    return match.group() == s if match else False
1204256
def regex_match(txt, rgx, ignorecase=False, multiline=False):
    '''
    
    '''
    flag = 0
    if ignorecase:
        flag |= re.I
    if multiline:
        flag |= re.M
    obj = re.match(rgx, txt, flag)
    if not obj:
        return
    return obj.groups()