aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_regex_stdlib.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-05-06 15:06:56 +0100
committerGravatar Sadie Powell2022-05-06 15:53:08 +0100
commitf7c041f5605bcfa09ed040f897b2615da6209594 (patch)
treeee54a3657624cde242e7be20d0afcc927114201b /src/modules/m_regex_stdlib.cpp
parentFix matching case-insensitive human regex patterns. (diff)
downloadinspircd++-f7c041f5605bcfa09ed040f897b2615da6209594.tar.gz
inspircd++-f7c041f5605bcfa09ed040f897b2615da6209594.tar.bz2
inspircd++-f7c041f5605bcfa09ed040f897b2615da6209594.zip
Implement support for regex capture groups.
Diffstat (limited to 'src/modules/m_regex_stdlib.cpp')
-rw-r--r--src/modules/m_regex_stdlib.cpp16
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