From 0e427a8416d889c24e5e481f6cb807e70ba81d2d Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 18 Jan 2018 17:46:44 +1100 Subject: [PATCH] fix regex quoting and escaping --- booking.helper.inc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/booking.helper.inc b/booking.helper.inc index aa4fef1..f7bf67c 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -38,24 +38,24 @@ function _booking_ucname($string) { // captialize all first letters //$string = preg_replace('/\\b(\\w)/e', 'strtoupper("$1")', strtolower(trim($string))); - $string = preg_replace_callback('/\\b(\\w)/', function ($m) { return strtoupper($m[1]); }, strtolower(trim($string))); + $string = preg_replace_callback("/\b(\w)/", function ($m) { return strtoupper($m[1]); }, strtolower(trim($string))); if ($all_uppercase) { // capitalize acronymns and initialisms e.g. PHP //$string = preg_replace("/\\b($all_uppercase)\\b/e", 'strtoupper("$1")', $string); - $string = preg_replace_callback('/\\b($all_uppercase)\\b/', function ($m) { return strtoupper($m[1]); }, $string); + $string = preg_replace_callback("/\b($all_uppercase)\b/", function ($m) { return strtoupper($m[1]); }, $string); } if ($all_lowercase) { // decapitalize short words e.g. and // all occurences will be changed to lowercase //$string = preg_replace("/\\b($all_lowercase)\\b/e", 'strtolower("$1")', $string); - $string = preg_replace_callback('/\\b($all_lowercase)\\b/', function ($m) { return strtolower($m[1]); }, $string); + $string = preg_replace_callback("/\b($all_lowercase)\b/", function ($m) { return strtolower($m[1]); }, $string); } if ($prefixes) { - watchdog('booking_debug', "Checking prefixes"); - preg_match("/\b($prefixes)(\w)/", $string, $matches); - watchdog('booking_debug', "
Prefixes match test: \n@info
", array('@info' => print_r( $matches, true))); + //watchdog('booking_debug', "Checking prefixes"); + //preg_match("/\b($prefixes)(\w)/", $string, $matches); + //watchdog('booking_debug', "
Prefixes match test: \n@info
", array('@info' => print_r( $matches, true))); // capitalize letter after certain name prefixes e.g 'Mc' //$string = preg_replace("/\\b($prefixes)(\\w)/e", '"$1".strtoupper("$2")', $string); $string = preg_replace_callback("/\b($prefixes)(\w)/", function ($m) { @@ -66,7 +66,7 @@ function _booking_ucname($string) { if ($suffixes) { // decapitalize certain word suffixes e.g. 's //$string = preg_replace("/(\\w)($suffixes)\\b/e", '"$1".strtolower("$2")', $string); - $string = preg_replace_callback('/(\\w)($suffixes)\\b/', function ($m) { return $m[1] . strtolower($m[2]); }, $string); + $string = preg_replace_callback("/(\w)($suffixes)\b/", function ($m) { return $m[1] . strtolower($m[2]); }, $string); } /*