lithium\util\Text::extract()
Extract a part of a string based on a regular expression $regex.
Parameters
-
string
$regexThe regular expression to use.
-
string
$strThe string to run the extraction on.
-
integer
$indexThe number of the part to return based on the regex.
Returns
mixedSource
public static function extract($regex, $str, $index = 0) {
if (!preg_match($regex, $str, $match)) {
return false;
}
return isset($match[$index]) ? $match[$index] : null;
}