summaryrefslogtreecommitdiff
path: root/src/regex.cc
blob: d2c8f615bcdb234cb6bbaeeef7ccc1bea42b5acf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "regex.hh"

#include "exception.hh"

namespace Kakoune
{

String option_to_string(const Regex& re)
{
    return String{re.str()};
}

void option_from_string(StringView str, Regex& re)
{
    try
    {
        re = Regex{str.begin(), str.end()};
    }
    catch (RegexError& err)
    {
        throw runtime_error("unable to create regex: "_str + err.what());
    }
}

}