From 0ce0f597f68dfae5cdd34026f0467343260f5a7b Mon Sep 17 00:00:00 2001 From: agree <37550360+greenbea@users.noreply.github.com> Date: Tue, 16 Jun 2020 22:35:51 -0400 Subject: [PATCH] Update functions.php (#5302) --- resources/functions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index 6bb3113db6..5eac3af9e1 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1708,6 +1708,7 @@ function number_pad($number,$n) { //converts a string to a regular expression if (!function_exists('string_to_regex')) { function string_to_regex($string, $prefix='') { + $original_string = $string; //escape the plus if (substr($string, 0, 1) == "+") { $string = "^\\+(".substr($string, 1).")$"; @@ -1723,9 +1724,11 @@ function number_pad($number,$n) { } } //convert N,X,Z syntax to regex - $string = str_ireplace("N", "[2-9]", $string); - $string = str_ireplace("X", "[0-9]", $string); - $string = str_ireplace("Z", "[1-9]", $string); + if (preg_match('/^[NnXxZz]+$/', $original_string)) { + $string = str_ireplace("N", "[2-9]", $string); + $string = str_ireplace("X", "[0-9]", $string); + $string = str_ireplace("Z", "[1-9]", $string); + } //add ^ to the start of the string if missing if (substr($string, 0, 1) != "^") { $string = "^".$string; @@ -2162,4 +2165,4 @@ function number_pad($number,$n) { } } -?> \ No newline at end of file +?>