Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Split string by a regular expression
<?php preg_split( string $pattern, string $subject, int $limit = -1, int $flags = 0): array|false
<?php case str_ends_with($token, '?'):
return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description);
case preg_match('/(.+)\=\*(.+)/', $token, $matches):
return new InputArgument($matches[1], InputArgument::IS_ARRAY, $description, preg_split('/,\s?/', $matches[2]));
case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]);
default:
<?php {
[$token, $description] = static::extractDescription($token);
$matches = preg_split('/\s*\|\s*/', $token, 2);
$shortcut = null;
<?php case str_ends_with($token, '=*'):
return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
case preg_match('/(.+)\=\*(.+)/', $token, $matches):
return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description, preg_split('/,\s?/', $matches[2]));
case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
default:
<?php protected static function extractDescription(string $token)
{
$parts = preg_split('/\s+:\s+/', trim($token), 2);
return count($parts) === 2 ? $parts : [$token, ''];
}
<?php protected function spliceIntoPosition($position, $value)
{
$segments = preg_split("/\s+/", $this->expression);
$segments[$position - 1] = $value;
<?php private function getCronExpressionSpacing($events)
{
$rows = $events->map(fn ($event) => array_map('mb_strlen', preg_split("/\s+/", $event->expression)));
return collect($rows[0] ?? [])->keys()->map(fn ($key) => $rows->max($key))->all();
}
<?php private function formatCronExpression($expression, $spacing)
{
$expressions = preg_split("/\s+/", $expression);
return collect($spacing)
->map(fn ($length, $index) => str_pad($expressions[$index], $length))
<?php $values = array_merge([$column => $timestamp], $values);
}
$segments = preg_split('/\s+as\s+/i', $this->query->from);
$qualifiedColumn = end($segments).'.'.$column;
<?php if (! $table) {
$words = preg_split('/(_)/u', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
$lastWord = array_pop($words);
<?php protected function wrapAliasedValue($value)
{
$segments = preg_split('/\s+as\s+/i', $value);
return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[1]);
}
<?php protected function wrapAliasedTable($value)
{
$segments = preg_split('/\s+as\s+/i', $value);
return $this->wrapTable($segments[0]).' as '.$this->wrapValue($this->tablePrefix.$segments[1]);
}
<?php {
$finder = substr($method, 5);
$segments = preg_split(
'/(And|Or)(?=[A-Z])/', $finder, -1, PREG_SPLIT_DELIM_CAPTURE
);
<?php $separator = str_contains(strtolower($columnString), ' as ') ? ' as ' : '\.';
return last(preg_split('~'.$separator.'~i', $columnString));
}
<?php $columns = $this->compileUpdateColumns($query, $values);
$alias = last(preg_split('/\s+as\s+/i', $query->from));
$selectSql = $this->compileSelect($query->select($alias.'.ctid'));
<?php {
$table = $this->wrapTable($query->from);
$alias = last(preg_split('/\s+as\s+/i', $query->from));
$selectSql = $this->compileSelect($query->select($alias.'.ctid'));