diff --git a/src/stan/io/json/json_data_handler.hpp b/src/stan/io/json/json_data_handler.hpp index 3e0adeb279d..b2b3faba655 100644 --- a/src/stan/io/json/json_data_handler.hpp +++ b/src/stan/io/json/json_data_handler.hpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -16,7 +16,6 @@ #include #include #include -#include namespace stan { @@ -172,8 +171,13 @@ class json_data_handler : public stan::json::json_handler { * and contain only letters, numbers, or an underscore. */ bool valid_varname(const std::string& name) { - static const boost::regex re("[a-zA-Z][a-zA-Z0-9_]*"); - return boost::regex_match(name, re); + static const std::locale& locale = std::locale::classic(); + if (name.empty() || !std::isalpha(name[0], locale)) { + return false; + } + return std::all_of(name.cbegin() + 1, name.cend(), [](const char c) { + return std::isalnum(c, locale) || c == '_'; + }); } bool is_array_tuples(const std::vector& keys) {