mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 09:21:30 +03:00
328c497be2
ECMAScript is adding support for it, and it is a pretty isolated change to do. Fixes #2293
29 lines
569 B
C++
29 lines
569 B
C++
#include "regex.hh"
|
|
#include "ranges.hh"
|
|
|
|
namespace Kakoune
|
|
{
|
|
|
|
Regex::Regex(StringView re, RegexCompileFlags flags)
|
|
: m_impl{new CompiledRegex{compile_regex(re, 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();
|
|
}
|
|
|
|
Regex option_from_string(Meta::Type<Regex>, StringView str)
|
|
{
|
|
return Regex{str};
|
|
}
|
|
|
|
}
|