mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Add Regex::clearBeginningSlash() and Regex::clearEndingSlash() methods (that remove slash from the beginning and the end of given string)
This commit is contained in:
@@ -40,6 +40,8 @@ class Regex
|
||||
'color' => '/^[a-f0-9]{6}$/i',
|
||||
'bundleName' => '/^(([A-Z]{1}[a-z0-9]+)((?2))*)(Bundle)$/',
|
||||
'binaryValue' => '/[^\x20-\x7E\t\r\n]/',
|
||||
'beginningSlash' => '|^\/|',
|
||||
'endingSlash' => '|\/$|',
|
||||
|
||||
/*
|
||||
* Matches:
|
||||
@@ -999,4 +1001,18 @@ class Regex
|
||||
|
||||
return preg_replace('/[-\s]+/', '-', $result);
|
||||
}
|
||||
|
||||
public static function clearBeginningSlash(string $string): string
|
||||
{
|
||||
$pattern = static::$patterns['beginningSlash'];
|
||||
|
||||
return preg_replace($pattern, '', $string);
|
||||
}
|
||||
|
||||
public static function clearEndingSlash(string $string): string
|
||||
{
|
||||
$pattern = static::$patterns['endingSlash'];
|
||||
|
||||
return preg_replace($pattern, '', $string);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user