| 119 | } |
| 120 | |
| 121 | StringHelper::Decomposition StringHelper::decomposeCaseInsensitiveMatch(std::string const& str, std::string const& toMatch) |
| 122 | { |
| 123 | std::string strLower = str; |
| 124 | std::string toMatchLower = toMatch; |
| 125 | |
| 126 | std::transform(str.begin(), str.end(), strLower.begin(), ::tolower); |
| 127 | std::transform(toMatch.begin(), toMatch.end(), toMatchLower.begin(), ::tolower); |
| 128 | |
| 129 | auto findResult = strLower.find(toMatchLower); |
| 130 | if (findResult == std::string::npos) { |
| 131 | return {.beforeMatch = str}; |
| 132 | } |
| 133 | |
| 134 | return {.beforeMatch = str.substr(0, findResult), .match = str.substr(findResult, toMatch.size())}; |
| 135 | } |