1 #include "regex.hh" 2 #include "ranges.hh" 3 4 namespace Kakoune 5 { 6 Regex(StringView re,RegexCompileFlags flags)7Regex::Regex(StringView re, RegexCompileFlags flags) 8 : m_impl{new CompiledRegex{}}, 9 m_str{re.str()} 10 { 11 *m_impl = compile_regex(re, flags); 12 } 13 named_capture_index(StringView name) const14int Regex::named_capture_index(StringView name) const 15 { 16 auto it = find_if(m_impl->named_captures, [&](auto& c) { return c.name == name; }); 17 return it != m_impl->named_captures.end() ? it->index : -1; 18 } 19 option_to_string(const Regex & re)20String option_to_string(const Regex& re) 21 { 22 return re.str(); 23 } 24 option_from_string(Meta::Type<Regex>,StringView str)25Regex option_from_string(Meta::Type<Regex>, StringView str) 26 { 27 return Regex{str}; 28 } 29 30 } 31