Laravel 8 match {#collection-method}
match
方法将会返回字符串和指定正则表达式匹配的部分:
use Illuminate\Support\Str;
$result = Str::of('foo bar')->match('/bar/');
// 'bar'
$result = Str::of('foo bar')->match('/foo (.*)/');
// 'bar'
match
方法将会返回字符串和指定正则表达式匹配的部分:
use Illuminate\Support\Str;
$result = Str::of('foo bar')->match('/bar/');
// 'bar'
$result = Str::of('foo bar')->match('/foo (.*)/');
// 'bar'