strip leading and trailing whitespace str = std::regex_replace(str, std::regex("^[ \t]+|[ \t]+$"), "");