Returns the first match from parameter array

@param array $params
@param string $regex
@return string
974775
private function getMatchingData(array $params, $regex)
    {
        foreach ($params as $data) {
            if (preg_match($regex, $data)) {
                return $data;
            }
        }

        return '';
    }
1289301
public function buildHashMatch($match, &$params)
    {
        $parts = [];

        foreach ($match as $column => $value) {
            $parts[] = $this->buildMatchColumn($column) . ' ' . $this->buildMatchValue($value, $params);
        }

        return count($parts) === 1 ? $parts[0] : '(' . implode(') (', $parts) . ')';
    }
91568
public function responseMatches($regex)
    {
        $actual = $this->session->getPage()->getContent();
        $message = sprintf('The pattern %s was not found anywhere in the HTML response of the page.', $regex);

        $this->assert((bool) preg_match($regex, $actual), $message);
    }
861236
def find_first_match regex #:nodoc:
      @list.each_with_index do |row, ix|
        return ix if !row.match(regex).nil?
      end
      return nil
    end
952130
function(regex, text){
    var nextIndex = 0;
    var result = [];

    var execResult;
    while ((execResult = regex.exec(text))!== null) {
        result.push({
            start: execResult.index, 
            matchLength: execResult[0].length});
    }

    return {
        next: function(){
            return nextIndex < result.length ?
                result[nextIndex++] :
                null;
        }
    };
}
1243490
public function regex(string $regex) : Text
    {
        return $this->pipe(
            self::predicate(
                function ($value) use ($regex) {
                    return preg_match($regex, $value) === 1;
                },
                "does not match $regex"
            )
        );
    }
1030952
private function getRanges(string $text, string $regex): array
	{
		preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);

		$ranges = array_map(function ($match) {
			return [$match[1], strlen($match[0])];
		}, $matches[0]);

		return $ranges;
	}
614996
function matches(regex, str) {
    var ret = [];
    var match = regex.exec(str);
    while (match !== null) {
        ret.push({
            full: match[0],
            inner: match[1]
        });
        match = regex.exec(str);
    }
    return ret;
}
659249
public Map<String, String> getValByRegex(String regex) {
    Pattern p = Pattern.compile(regex);

    Map<String, String> result = new HashMap<String, String>();
    Matcher m;

    for (Map.Entry<Object, Object> item: getProps().entrySet()) {
      if (item.getKey() instanceof String &&
            item.getValue() instanceof String) {
        m = p.matcher((String) item.getKey());
        if (m.find()) { // match
          result.put((String) item.getKey(), (String) item.getValue());
        }
      }
    }
    return result;
  }
713520
public function match($regexp, $tagName)
	{
		$tagName        = TagName::normalize($tagName);
		$passthroughIdx = 0;
		$this->parseRegexp($regexp);
		foreach ($this->captures as $i => $capture)
		{
			if (!$this->isCatchAll($capture['expr']))
			{
				continue;
			}
			$passthroughIdx = $i;
		}

		$this->collection[] = [$tagName, $regexp, $passthroughIdx];
	}
435130
public function with(string $param, string $regex): Route{
		$this->params[$param] = str_replace('(', '(?:', $regex);
		return $this;
	}
627686
function(regex){
		//if it isn't global, `exec()` will not start at `lastIndex`
		if(!regex.global)
			regex.compile(regex.source, flags(regex));
		regex.lastIndex = this.position;
		var m = regex.exec(this.source);

		//all matches must start at the current position.
		if(m && m.index!=this.position){
			return null;
		}

		if(m) this.position += m[0].length;
		return m;
	}
1002468
public function matchQuery($pattern, &$matches = null, $flags = 0, $offset = 0)
	{
		return preg_match($pattern, $this->_query ?: '', $matches, $flags, $offset);
	}
911165
public static boolean regexMatch(String input, String regex) {
        return Pattern.compile(regex).matcher(input).matches();
    }
717493
public function buildMatch($match, &$params)
    {
        if (empty($match)) {
            return '';
        }

        if ($match instanceof Expression) {
            return $this->buildMatchValue($match, $params);
        }

        if (!is_array($match)) {
            return $match;
        }

        if (isset($match[0])) {
            // operator format: operator, operand 1, operand 2, ...
            $operator = strtoupper($match[0]);
            if (isset($this->matchBuilders[$operator])) {
                $method = $this->matchBuilders[$operator];
            } else {
                $method = 'buildSimpleMatch';
            }
            array_shift($match);
            return $this->$method($operator, $match, $params);
        }

        // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
        return $this->buildHashMatch($match, $params);
    }
321679
public function itemsFilterFirst($params) {
		$params2 = $params;
		$params2['limit'] = 1;
		$list = $this->itemsFilter($params2);
		if (empty($list)) {
			return NULL;
		}
		$item = reset($list);
		return $item;
	}
163038
public function getMethodsByPattern($regex)
    {
    	$methods = array();
        foreach ($this->xmlRoot->method as $method) {
    		if (preg_match("/$regex/", $method['name'])) {
		        $moufRefMethod = new MoufXmlReflectionMethod($this, $method);
		        $methods[] = $moufRefMethod;
    		}
    	}
    	return $methods;
    }