From 4b88a1085ceb7380edea1647a43e71da69e45e5d Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Sat, 22 May 2021 02:46:07 +0200 Subject: [PATCH 1/2] Replace regex in Str::placeholders (#37) --- src/Str.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Str.php b/src/Str.php index d1f91ac..84b6691 100644 --- a/src/Str.php +++ b/src/Str.php @@ -428,7 +428,7 @@ public static function mb_substr_replace($string, $replacement, $start, $length public static function placeholders(string $string, array $replacements, bool $caseInsensitive = false): string { - $regex = '/{([A-Z0-9_]+)}/' . ($caseInsensitive ? 'i' : ''); + $regex = '/([a-zA-Z0-9_.-]+)/' . ($caseInsensitive ? 'i' : ''); return preg_replace_callback( $regex, From b74f9798f6c88ad8c4751d526effd3728978c822 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Mon, 14 Jun 2021 17:45:39 +0200 Subject: [PATCH 2/2] update regexp with optional bracket and default lowercase char --- src/Str.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Str.php b/src/Str.php index 84b6691..60fa6b5 100644 --- a/src/Str.php +++ b/src/Str.php @@ -428,7 +428,7 @@ public static function mb_substr_replace($string, $replacement, $start, $length public static function placeholders(string $string, array $replacements, bool $caseInsensitive = false): string { - $regex = '/([a-zA-Z0-9_.-]+)/' . ($caseInsensitive ? 'i' : ''); + $regex = '/{?([a-z0-9_]+)}?/' . ($caseInsensitive ? 'i' : ''); return preg_replace_callback( $regex,