46 Error.resize(len - 1);
58 unsigned nmatch = Matches ? preg->
re_nsub+1 : 0;
62 pm.
resize(nmatch > 0 ? nmatch : 1);
64 pm[0].rm_eo = String.
size();
81 for (
unsigned i = 0; i != nmatch; ++i) {
82 if (pm[i].rm_so == -1) {
87 assert(pm[i].rm_eo >= pm[i].rm_so);
89 pm[i].rm_eo-pm[i].rm_so));
101 if (Error && !Error->empty()) *Error =
"";
104 if (!
match(String, &Matches))
109 std::string Res(String.
begin(), Matches[0].
begin());
112 while (!Repl.
empty()) {
114 std::pair<StringRef, StringRef>
Split = Repl.
split(
'\\');
120 if (Split.second.empty()) {
121 if (Repl.
size() != Split.first.size() &&
122 Error && Error->empty())
123 *Error =
"replacement string contained trailing backslash";
149 case '0':
case '1':
case '2':
case '3':
case '4':
150 case '5':
case '6':
case '7':
case '8':
case '9': {
157 RefValue < Matches.
size())
158 Res += Matches[RefValue];
159 else if (Error && Error->empty())
160 *Error =
"invalid backreference string '" + Ref.
str() +
"'";
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
size_t size() const
size - Get the string size.
std::pair< StringRef, StringRef > split(char Separator) const
StringRef substr(size_t Start, size_t N=npos) const
int llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
std::string str() const
str - Get the contents as an std::string.
void llvm_regfree(llvm_regex_t *)
Compile for matching that ignores upper/lower case distinctions.
bool isValid(std::string &Error)
const char * data() const
size_t llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size)
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=0)
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str...
enable_if_c< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
size_t find_first_not_of(char C, size_t From=0) const
unsigned getNumMatches() const
Regex(StringRef Regex, unsigned Flags=NoFlags)
Compiles the given regular expression Regex.
static void Split(std::vector< std::string > &V, const StringRef S)
std::string sub(StringRef Repl, StringRef String, std::string *Error=0)
int llvm_regexec(const llvm_regex_t *, const char *, size_t, llvm_regmatch_t[], int)
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
size_t find_first_of(char C, size_t From=0) const
StringRef slice(size_t Start, size_t End) const
bool empty() const
empty - Check if the string is empty.