diff --git a/src/inja.hpp b/src/inja.hpp index 1e307be..3c8302f 100644 --- a/src/inja.hpp +++ b/src/inja.hpp @@ -501,15 +501,15 @@ public: {Parsed::Function::GreaterEqual, Regex{"(.+) >= (.+)"}}, {Parsed::Function::LessEqual, Regex{"(.+) <= (.+)"}}, {Parsed::Function::Different, Regex{"(.+) != (.+)"}}, - {Parsed::Function::Upper, Regex{"upper\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Lower, Regex{"lower\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Range, Regex{"range\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Length, Regex{"length\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Round, Regex{"round\\(\\s*(.*?)\\s*,\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::DivisibleBy, Regex{"divisibleBy\\(\\s*(.*?)\\s*,\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Odd, Regex{"odd\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::Even, Regex{"even\\(\\s*(.*?)\\s*\\)"}}, - {Parsed::Function::ReadJson, Regex{"\\s*([^()]*)\\s*"}} + {Parsed::Function::Upper, Regex{"upper\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Lower, Regex{"lower\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Range, Regex{"range\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Length, Regex{"length\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Round, Regex{"round\\(\\s*(.*)\\s*,\\s*(.*)\\s*\\)"}}, + {Parsed::Function::DivisibleBy, Regex{"divisibleBy\\(\\s*(.*)\\s*,\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Odd, Regex{"odd\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::Even, Regex{"even\\(\\s*(.*)\\s*\\)"}}, + {Parsed::Function::ReadJson, Regex{"\\s*([^()]*?)\\s*"}} }; Parser() { } diff --git a/test/src/unit-string-helper.cpp b/test/src/unit-string-helper.cpp index e3e1d03..58a7f0c 100644 --- a/test/src/unit-string-helper.cpp +++ b/test/src/unit-string-helper.cpp @@ -48,6 +48,13 @@ TEST_CASE("search-with-multiple-possible-regexes") { CHECK( match.str() == "ipsum" ); CHECK( match.str(1) == "s" ); } + + SECTION("basic 3") { + std::vector regex_patterns = { inja::Regex("upper\\((.*)\\)"), inja::Regex("lower\\((.*)\\)"), inja::Regex("[^()]*?") }; + inja::Match match = inja::search("upper(lower(name))", regex_patterns, 0); + CHECK( match.regex_number() == 0 ); + CHECK( match.str(1) == "lower(name)" ); + } } TEST_CASE("search-on-level") {