lithium\util\String::extract()

public static method

Extract a part of a string based on a regular expression $regex.

Parameters

  • string $regex

    The regular expression to use.

  • string $str

    The string to run the extraction on.

  • integer $index

    The number of the part to return based on the regex.

Returns

mixed

Source

	public static function extract($regex, $str, $index = 0) {
		if (!preg_match($regex, $str, $match)) {
			return false;
		}
		return isset($match[$index]) ? $match[$index] : null;
	}