Skip to content

Commit

Permalink
Merge branch 'patch-1' of https://github.com/tuarrep/framework into t…
Browse files Browse the repository at this point in the history
…uarrep-patch-1
  • Loading branch information
taylorotwell committed May 8, 2020
2 parents cb39818 + 87bb135 commit 9f34210
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,25 @@ public function explode($delimiter, $limit = PHP_INT_MAX)
return collect(explode($delimiter, $this->value, $limit));
}

/**
* Split string by a regular expression.
*
* @param string $pattern
* @param int $limit
* @param int $flags
* @return \Illuminate\Support\Collection
*/
public function split($pattern, $limit = -1, $flags = 0)
{
$keywords = preg_split($pattern, $this->value, $limit, $flags);

if (! $keywords) {
return collect();
}

return collect($keywords);
}

/**
* Cap a string with a single instance of a given value.
*
Expand Down

0 comments on commit 9f34210

Please sign in to comment.