diff options
Diffstat (limited to 'src/modules/m_regex_stdlib.cpp')
| -rw-r--r-- | src/modules/m_regex_stdlib.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/m_regex_stdlib.cpp b/src/modules/m_regex_stdlib.cpp index 0f2d31a61..191625221 100644 --- a/src/modules/m_regex_stdlib.cpp +++ b/src/modules/m_regex_stdlib.cpp @@ -54,6 +54,22 @@ public: { return std::regex_search(text, regex); } + + std::optional<Regex::MatchCollection> Matches(const std::string& text) override + { + std::smatch matches; + if (!std::regex_search(text, matches, regex)) + return std::nullopt; + + Regex::Captures captures(matches.size()); + for (const auto& match : matches) + captures.push_back(match); + + // The stdregex engine does not support named captures. + static const Regex::NamedCaptures unusednc; + + return Regex::MatchCollection(std::move(captures), unusednc); + } }; class StdLibEngine final |
