18 static const std::regex expression(
"\\$(([A-Za-z0-9_]+)|\\(([A-Za-z0-9_]+)\\))" );
20 std::string result = std::string{ input };
21 auto start = input.begin();
22 auto end = input.end();
23 std::match_results<std::string_view::const_iterator> what;
24 auto flags = std::regex_constants::match_default;
26 while ( std::regex_search(
start,
end, what, expression, flags ) ) {
27 if ( std::string env;
System::getEnv( what[what[2].matched ? 2 : 3].str(), env ) ) {
28 auto pos = result.find( what[0].first, from, what[0].length() );
29 result.replace( pos, what[0].length(), env );
30 from = pos + env.size();
32 start = what[0].second;
34 flags |= std::regex_constants::match_prev_avail;