Match the subject against all the matcher's patterns.

        Args:
            subject: The subject to match.

        Yields:
            For every match, a tuple of the matching pattern and the match substitution.
482801
def match(self, subject: Expression) -> Iterator[Tuple[Expression, Substitution]]:
        
        return _MatchIter(self, subject)
142393
def matches_conditions_hash?(subject, conditions = @conditions)
      return true if conditions.empty?

      adapter = model_adapter(subject)

      if adapter.override_conditions_hash_matching?(subject, conditions)
        return adapter.matches_conditions_hash?(subject, conditions)
      end

      matches_all_conditions?(adapter, conditions, subject)
    end
845750
def replace_subject(rdf, fromuri, touri):
    
    if fromuri == touri:
        return
    for p, o in rdf.predicate_objects(fromuri):
        rdf.remove((fromuri, p, o))
        if touri is not None:
            if not isinstance(touri, (list, tuple)):
                touri = [touri]
            for uri in touri:
                rdf.add((uri, p, o))
223613
public static String preg_replace(String regex, String replacement, String subject) {
        Pattern p = Pattern.compile(regex);
        return preg_replace(p, replacement, subject);
    }
656322
public boolean checkRegexPattern(final Optional<Subject> subjectOption,
                                     final Optional<Pattern> patternOption)
    {
        final boolean[] roleOk = {false};
        subjectOption.ifPresent(subject -> patternOption.ifPresent(pattern -> {
            final List<? extends Permission> permissions = subject.getPermissions();
            if (permissions != null)
            {
                for (Iterator<? extends Permission> iterator = permissions.iterator(); !roleOk[0] && iterator.hasNext(); )
                {
                    final Permission permission = iterator.next();
                    roleOk[0] = pattern.matcher(permission.getValue()).matches();
                }
            }
        }));

        return roleOk[0];
    }
261014
public static int preg_match(Pattern pattern, String subject) {
        int matches=0;
        Matcher m = pattern.matcher(subject);
        while(m.find()){ 
            ++matches;
        }
        return matches;
    }
4243
def dict_replace(subject_dict, string):
    
    for i, j in subject_dict.items():
        string = string.replace(i, j)
    return string
543040
def relevant_rules_for_match(self, action, subject):
        """"""
        matches = []
        for rule in self.rules:
            rule.expanded_actions = self.expand_actions(rule.actions)
            if rule.is_relevant(action, subject):
                matches.append(rule)

        return self.optimize(matches[::-1])
216425
def equals(self, other):
        
        self._run(unittest_case.assertEqual, (self._subject, other))
        return ChainInspector(self._subject)
998092
def subject
      return nil unless subject_decorator
      if subject_decorator.respond_to?(:call)
        subject_decorator.call()
      elsif respond_to?(subject_decorator)
        self.send(subject_decorator)
      else
        nil
      end
    end
575439
def match(self, user, message):
        
        self._log.info('Attempting to match message against Pattern: {pattern}'
                       .format(pattern=self.pattern.pattern if hasattr(self.pattern, 'pattern') else self.pattern))
        self.user = user

        # Make sure the topic matches (if one is defined)
        if user.topic != self.topic:
            self._log.debug('User topic "{u_topic}" does not match Trigger topic "{t_topic}", skipping check'
                            .format(u_topic=user.topic, t_topic=self.topic))
            return

        def get_response():
            # Does the user have a limit for this response enforced?
            if user.is_limited(self):
                if self.ulimit_blocking:
                    self._log.debug('An active blocking limit for this trigger is being enforced against the user '
                                    '{uid}, no trigger will be matched'.format(uid=user.id))
                    raise LimitError

                self._log.debug('An active limit for this response is being enforced against the user {uid}, '
                                'skipping'.format(uid=user.id))
                return ''

            # Is there a global limit for this response enforced?
            if self.agentml.is_limited(self):
                if self.glimit_blocking:
                    self._log.debug('An active blocking limit for this trigger is being enforced globally, no trigger '
                                    'will be matched')
                    raise LimitError

                self._log.debug('An active limit for this response is being enforced against the user {uid}, '
                                'skipping'.format(uid=user.id))
                return ''

            # Chance testing
            if self.chance is not None and self.chance != 100:
                # Chance succeeded
                if self.chance >= random.uniform(0, 100):
                    self._log.info('Trigger had a {chance}% chance of being selected and succeeded selection'
                                   .format(chance=self.chance))
                # Chance failed
                else:
                    if self.chance_blocking:
                        self._log.info('Trigger had a blocking {chance}% chance of being selected but failed selection'
                                       ', no trigger will be matched'.format(chance=self.chance))
                        raise ChanceError

                    self._log.info('Response had a {chance}% chance of being selected but failed selection'
                                   .format(chance=self.chance))
                    return ''

            random_response = self._responses.random(user)
            if not random_response and self.blocking:
                self._log.info('Trigger was matched, but there are no available responses and the trigger is blocking '
                               'any further attempts. Giving up')
                raise ParserBlockingError

            if random_response:
                self.apply_reactions(user)
            else:
                self._log.info('Trigger was matched, but there are no available responses')
                random_response = ''

            return random_response

        # String match
        if isinstance(self.pattern, string_types) and str(message) == self.pattern:
            self._log.info('String Pattern matched: {match}'.format(match=self.pattern))
            return get_response()

        # Regular expression match
        if hasattr(self.pattern, 'match'):
            match = self.pattern.match(str(message))
            if match:
                self._log.info('Regex pattern matched: {match}'.format(match=self.pattern.pattern))

                # Parse pattern wildcards
                self.stars['normalized'] = match.groups()
                for message_format in [message.CASE_PRESERVED, message.RAW]:
                    message.format = message_format
                    format_match = self.pattern.match(str(message))
                    if format_match:
                        self.stars[message_format] = format_match.groups()

                self._log.debug('Assigning pattern wildcards: {stars}'.format(stars=str(self.stars)))
                return get_response()
350823
public function matches($subject)
    {
        if ($this->pattern === null) {
            throw new RegexpException("No pattern specified for regexp match().");
        }

        return $this->engine->match($this->pattern, $subject, $this->groups);
    }
668609
function deepMatches(target, pattern){
        if (target && typeof target === 'object') {
            if (isArray(target) && isArray(pattern)) {
                return matchArray(target, pattern);
            } else {
                return matchObject(target, pattern);
            }
        } else {
            return target === pattern;
        }
    }
32312
public function match(Subject $subject, string $verb): bool
    {
        return $this->subject->getType() == $subject->getType() &&
            $this->subject->getId() === $subject->getId() &&
            ($this->verbs === null || in_array($verb, $this->verbs, true));
    }
1218400
def rdf_find_subject(id)
      return nil unless rdf_valid?
      rdf.each_subject do |s|
        return s if s.to_s =~ Regexp.new(id, Regexp::IGNORECASE)
      end
      nil
    end
1034894
protected function matchAuthzGroupPaths($pattern, $subject)
    {
        $regex = '^' . str_replace('[^/]+', '\\*', preg_quote($pattern, '~')) . '$';
        $regex = str_replace('\\*', '(.*)', $regex);

        $match = preg_match('~' . $regex . '~i', $subject);

        return $match;
    }
789104
private static function matchesAny(array $regexes, $subject)
    {
        $matches = null;
        foreach ($regexes as $regex) {
            if ( ! in_array(preg_match("/$regex/", $subject, $matches), [0, false])) {
                return $matches;
            }
        }
    }