Get all matches by regex
@param string $regex
@return \PerrysLambda\ArrayList
325257
public function matchAll($regex)
    {
        $matches = array();
        $result = preg_match_all($regex, $this->toString(), $matches, PREG_SET_ORDER);
        if($this->isValidRegex($regex) && $result!==false && $result>0)
        {
            return ArrayList::asObjectArray($matches);
        }
        return null;
    }
360577
protected function findRealPathFiles(string $regex, string $path) {
		if(!is_dir($path))
			return null;
				
		$files = $this->findFilesAsSplFileInfo($regex, $path);
		$result = [];
		
		foreach ($files as $item) {
			
			if($item instanceof SplFileInfo)
				$result[] = $item->getRealPath();			
		}
		
		return !empty($result) ? $result : null;
	}
72190
protected function getMatches($regexp, $limit)
	{
		$cnt = preg_match_all($regexp, $this->text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
		if ($cnt > $limit)
		{
			$matches = array_slice($matches, 0, $limit);
		}

		return $matches;
	}
1304999
protected function getMatches($source)
    {
        if ($this->hasMatches($source)) {
            preg_match_all($this->pattern, $source, $matches, PREG_SET_ORDER);

            return $matches;
        }
    }
850887
private function get_arg_or_param_args( $regex ) {
		$bits       = explode( "\n", $this->doc_comment );
		$within_arg = false;
		$within_doc = false;
		$document   = array();
		foreach ( $bits as $bit ) {
			if ( preg_match( $regex, $bit ) ) {
				$within_arg = true;
			}

			if ( $within_arg && $within_doc && '---' === $bit ) {
				$within_doc = false;
			}

			if ( $within_arg && ! $within_doc && '---' === $bit ) {
				$within_doc = true;
			}

			if ( $within_doc ) {
				$document[] = $bit;
			}

			if ( $within_arg && '' === $bit ) {
				$within_arg = false;
				break;
			}
		}

		if ( $document ) {
			return Spyc::YAMLLoadString( implode( "\n", $document ) );
		}
		return null;
	}
193512
protected function parsePlaceholders($pattern)
    {
        $params = [];
        $parser = $this->parser;

        preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER);

        foreach ((array) $matches as $key => $match) {
            $pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern);
            $params[$key] = $match[1];
        }

        return [$pattern, $params];
    }
2556
public function matches($key, $regex, &$matches = [])
    {
        if (!$this->has($key, self::HAS_ISSET)) {
            return false;
        }

        return (bool) preg_match($regex, $this->get($key), $matches);
    }
962629
public static File[] findMatches( File directory , String regex ) {
		final Pattern p = Pattern.compile(regex); // careful: could also throw an exception!
		return directory.listFiles(file -> p.matcher(file.getName()).matches());
	}
23150
public function split( $regex, $limit = - 1 ) {
		$parts = preg_split( $regex, $this->value, $limit );
		for ( $i = 0, $l = count( $parts ); $i < $l; $i ++ ) {
			$parts[ $i ] = new GString( $parts[ $i ] );
		}

		return $parts;
	}
40747
public function getNextStrpos($patterns)
    {
        $next = -1;
        $match = null;
        foreach ($patterns as $p) {
            $index = strpos($this->src, $p, $this->index);
            if ($index === false) {
                continue;
            }
            if ($next === -1 || $index < $next) {
                $next = $index;
                $match = $p;
            }
        }
        return array($next, $match);
    }
1301196
protected static function replaceAllRegex($regex, $requirements = [])
    {
        $find = chr(1) . '\(([a-z][a-zA-Z0-9_]*)\)' . chr(1);

        preg_match_all($find, $regex, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            $name = $match[1];
            $subpattern = static::requirementPattern($name, $requirements);
            $regex = str_replace("({$name})", $subpattern, $regex);
        }

        return $regex;
    }
486677
public function setPathRegex($regex)
    {
        if ($regex === null) {
            $this->pathRegex = null;
            return $this;
        }

        $this->pathRegex = $regex;
        return $this;
    }
926461
public List<String> findList(String str, String regex) {
		ArrayList<String> ret = new ArrayList<String>();
		if (str == null || regex == null)
			return ret;
		Matcher m = Pattern.compile(regex).matcher(str);
		while (m.find()) {
			ret.add(m.group());
		}
		return ret;
	}
1352671
public List<String> getKeysFromRegex(String regex) {
        List<String> keys = Lists.newArrayList();
        
        try {
            // List all objects in the domain
            ObjectName name = new ObjectName(regex);
            Set<ObjectName> objs = mBeanServer.queryNames(name, null);
            
            // Convert object naems to a tree
            for (ObjectName objName : objs) {
                MBeanInfo info = mBeanServer.getMBeanInfo(objName);
                keys.add(objName.getCanonicalName());
            }
        } catch (Exception e) {
            LOG.error("Exception in getKeysFromRegex ", e);
        }
        
        return keys;
    }
1209492
public function match(string $event): array
    {
        $matches = [];

        //do the obvious match
        if (isset($this->observers[$event])) {
            $matches[$event] = array(
                'event' => $event,
                'pattern' => $event,
                'variables' => []
            );
        }

        //deal with regexp
        foreach ($this->regex as $pattern) {
            //if it matches
            if (preg_match_all($pattern, $event, $match)) {
                $variables = [];

                if (is_array($match) && !empty($match)) {
                    //flatten
                    $variables = call_user_func_array('array_merge', $match);
                    array_shift($variables);
                }

                $matches[$pattern] = array(
                    'event' => $event,
                    'pattern' => $pattern,
                    'variables' => $variables
                );
            }
        }

        return array_values($matches);
    }
881810
public function trim($regex = Strings::TRIM_CHARACTERS)
    {
        $this->_string = Strings::trim($this->_string, $regex);
        $this->_direction = null;

        return $this;
    }
571933
public function pageTextNotMatches($regex)
    {
        $actual = $this->session->getPage()->getText();
        $message = sprintf('The pattern %s was found in the text of the current page, but it should not.', $regex);

        $this->assertResponseText(!preg_match($regex, $actual), $message);
    }