diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js index 90a969ad27..b9fcd4f9de 100644 --- a/js/server/ahuacatl.js +++ b/js/server/ahuacatl.js @@ -1293,6 +1293,19 @@ function AHUACATL_STRING_SUBSTRING (value, offset, count) { return value.substr(offset, count); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief searches a substring in a string +/// +/// the two input operands must be strings or this function will fail +//////////////////////////////////////////////////////////////////////////////// + +function AHUACATL_STRING_CONTAINS (value, search) { + AHUACATL_ARG_CHECK(value, AHUACATL_TYPEWEIGHT_STRING, "CONTAINS"); + AHUACATL_ARG_CHECK(offset, AHUACATL_TYPEWEIGHT_STRING, "CONTAINS"); + + return value.indexOf(search) != -1; +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h index ea36d5b5cb..ecfcc1c163 100644 --- a/js/server/js-ahuacatl.h +++ b/js/server/js-ahuacatl.h @@ -1295,6 +1295,19 @@ static string JS_server_ahuacatl = "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" + "/// @brief searches a substring in a string\n" + "///\n" + "/// the two input operands must be strings or this function will fail\n" + "////////////////////////////////////////////////////////////////////////////////\n" + "\n" + "function AHUACATL_STRING_CONTAINS (value, search) {\n" + " AHUACATL_ARG_CHECK(value, AHUACATL_TYPEWEIGHT_STRING, \"CONTAINS\");\n" + " AHUACATL_ARG_CHECK(offset, AHUACATL_TYPEWEIGHT_STRING, \"CONTAINS\");\n" + "\n" + " return value.indexOf(search) != -1;\n" + "}\n" + "\n" + "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n"