blob: a6891bd2114c3256b63e306965b98b7b1e2b62c1 (
plain) (
blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/stllike/string.h>
namespace vespalib {
/**
* Utility class inspecting and generating regular expression strings.
**/
class RegexpUtil
{
public:
/**
* Look at the given regular expression and identify the prefix
* that must be present for a string to match it. Note that an
* un-anchored expression will have an empty prefix. Also note
* that this function is simple and might underestimate the actual
* size of the prefix.
*
* @param re Regular expression.
* @return prefix that must be present in matching strings
**/
static vespalib::string get_prefix(vespalib::stringref re);
/**
* Make a regexp matching strings with the given suffix.
*
* @param suffix the suffix
* @return the regexp
**/
static vespalib::string make_from_suffix(vespalib::stringref suffix);
/**
* Make a regexp matching strings with the given substring.
*
* @param substring the substring
* @return the regexp
**/
static vespalib::string make_from_substring(vespalib::stringref substring);
};
} // namespace vespalib
|