summaryrefslogtreecommitdiff
path: root/src/regex.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-01-03 22:52:15 +1100
committerMaxime Coste <mawww@kakoune.org>2019-01-03 22:55:50 +1100
commit328c497be248faf4e13aaececaf849c844c59efe (patch)
treeeb3d225fc81389afc8938593f065cf715804d75d /src/regex.cc
parent56ee329d79d076742e60c10974c471cc8119ed05 (diff)
Add support for named captures to the regex impl and regex highlighter
ECMAScript is adding support for it, and it is a pretty isolated change to do. Fixes #2293
Diffstat (limited to 'src/regex.cc')
-rw-r--r--src/regex.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/regex.cc b/src/regex.cc
index 970721c7..389b2376 100644
--- a/src/regex.cc
+++ b/src/regex.cc
@@ -1,4 +1,5 @@
#include "regex.hh"
+#include "ranges.hh"
namespace Kakoune
{
@@ -8,6 +9,12 @@ Regex::Regex(StringView re, RegexCompileFlags flags)
m_str{re.str()}
{}
+int Regex::named_capture_index(StringView name) const
+{
+ auto it = find_if(m_impl->named_captures, [&](auto& c) { return c.name == name; });
+ return it != m_impl->named_captures.end() ? it->index : -1;
+}
+
String option_to_string(const Regex& re)
{
return re.str();