From 11d3ced872fac144157d9d2d4e6faad87e390086 Mon Sep 17 00:00:00 2001 From: Marco Lipparini <1532277+liarco@users.noreply.github.com> Date: Mon, 21 Feb 2022 09:12:13 +0100 Subject: [PATCH 1/2] Functions might have underscores in their names --- src/EthereumStatic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EthereumStatic.php b/src/EthereumStatic.php index eaac9f7..6df8848 100644 --- a/src/EthereumStatic.php +++ b/src/EthereumStatic.php @@ -105,8 +105,8 @@ public static function sha3($string) public static function isValidFunction($input) { // Check for function and Params. - // See: https://regex101.com/r/437FZz/4 - $regex = '/^[a-zA-Z]+[a-zA-Z0-9]*[\(]{1}(([\w\d\[\]*){1}(\,[\w\d\[\]]*[\w\d\[\]]*)*)[\)]{1}$/'; + // See: https://regex101.com/r/7KRDNT/1 + $regex = '/^[a-zA-Z_]+[a-zA-Z0-9_]*[\(]{1}(([\w\d\[\]*){1}(\,[\w\d\[\]]*[\w\d\[\]]*)*)[\)]{1}$/'; if (is_string($input) && preg_match($regex, $input) === 1) { return true; } From 82bfb566fa66890d4326782c36c0a798224542f3 Mon Sep 17 00:00:00 2001 From: Marco Lipparini <1532277+liarco@users.noreply.github.com> Date: Mon, 21 Feb 2022 09:17:00 +0100 Subject: [PATCH 2/2] Adding test with numbers on regex101 --- src/EthereumStatic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EthereumStatic.php b/src/EthereumStatic.php index 6df8848..c1db6b6 100644 --- a/src/EthereumStatic.php +++ b/src/EthereumStatic.php @@ -105,7 +105,7 @@ public static function sha3($string) public static function isValidFunction($input) { // Check for function and Params. - // See: https://regex101.com/r/7KRDNT/1 + // See: https://regex101.com/r/njQeMs/1 $regex = '/^[a-zA-Z_]+[a-zA-Z0-9_]*[\(]{1}(([\w\d\[\]*){1}(\,[\w\d\[\]]*[\w\d\[\]]*)*)[\)]{1}$/'; if (is_string($input) && preg_match($regex, $input) === 1) { return true;