class Regex
Declaration
class Regex { /* full declaration omitted */ };
Declared at: llvm/include/llvm/Support/Regex.h:27
Method Overview
- public Regex()
- public Regex(llvm::StringRef Regex, unsigned int Flags = NoFlags)
- public Regex(const llvm::Regex &)
- public Regex(llvm::Regex && regex)
- public static std::string escape(llvm::StringRef String)
- public unsigned int getNumMatches() const
- public static bool isLiteralERE(llvm::StringRef Str)
- public bool isValid(std::string & Error) const
- public bool isValid() const
- public bool match(llvm::StringRef String, SmallVectorImpl<llvm::StringRef> * Matches = nullptr, std::string * Error = nullptr) const
- public std::string sub(llvm::StringRef Repl, llvm::StringRef String, std::string * Error = nullptr) const
- public ~Regex()
Methods
¶Regex()
Regex()
Declared at: llvm/include/llvm/Support/Regex.h:45
¶Regex(llvm::StringRef Regex,
unsigned int Flags = NoFlags)
Regex(llvm::StringRef Regex,
unsigned int Flags = NoFlags)
Description
Compiles the given regular expression \p Regex.
Declared at: llvm/include/llvm/Support/Regex.h:50
Parameters
- llvm::StringRef Regex
- - referenced string is no longer needed after this constructor does finish. Only its compiled form is kept stored.
- unsigned int Flags = NoFlags
¶Regex(const llvm::Regex&)
Regex(const llvm::Regex&)
Declared at: llvm/include/llvm/Support/Regex.h:51
Parameters
- const llvm::Regex&
¶Regex(llvm::Regex&& regex)
Regex(llvm::Regex&& regex)
Declared at: llvm/include/llvm/Support/Regex.h:57
Parameters
- llvm::Regex&& regex
¶static std::string escape(llvm::StringRef String)
static std::string escape(llvm::StringRef String)
Description
Turn String into a regex by escaping its special characters.
Declared at: llvm/include/llvm/Support/Regex.h:101
Parameters
- llvm::StringRef String
¶unsigned int getNumMatches() const
unsigned int getNumMatches() const
Description
getNumMatches - In a valid regex, return the number of parenthesized matches it contains. The number filled in by match will include this many entries plus one for the whole regex (as element 0).
Declared at: llvm/include/llvm/Support/Regex.h:68
¶static bool isLiteralERE(llvm::StringRef Str)
static bool isLiteralERE(llvm::StringRef Str)
Description
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str.
Declared at: llvm/include/llvm/Support/Regex.h:98
Parameters
- llvm::StringRef Str
¶bool isValid(std::string& Error) const
bool isValid(std::string& Error) const
Description
isValid - returns the error encountered during regex compilation, if any.
Declared at: llvm/include/llvm/Support/Regex.h:62
Parameters
- std::string& Error
¶bool isValid() const
bool isValid() const
Declared at: llvm/include/llvm/Support/Regex.h:63
¶bool match(llvm::StringRef String,
SmallVectorImpl<llvm::StringRef>*
Matches = nullptr,
std::string* Error = nullptr) const
bool match(llvm::StringRef String,
SmallVectorImpl<llvm::StringRef>*
Matches = nullptr,
std::string* Error = nullptr) const
Description
matches - Match the regex against a given \p String. This returns true on a successful match.
Declared at: llvm/include/llvm/Support/Regex.h:80
Parameters
- llvm::StringRef String
- SmallVectorImpl<llvm::StringRef>* Matches = nullptr
- - If given, on a successful match this will be filled in with references to the matched group expressions (inside \p String), the first group is always the entire pattern.
- std::string* Error = nullptr
- - If non-null, any errors in the matching will be recorded as a non-empty string. If there is no error, it will be an empty string.
¶std::string sub(
llvm::StringRef Repl,
llvm::StringRef String,
std::string* Error = nullptr) const
std::string sub(
llvm::StringRef Repl,
llvm::StringRef String,
std::string* Error = nullptr) const
Description
sub - Return the result of replacing the first match of the regex in\p String with the \p Repl string. Backreferences like "\0" in the replacement string are replaced with the appropriate match substring. Note that the replacement string has backslash escaping performed on it. Invalid backreferences are ignored (replaced by empty strings).
Declared at: llvm/include/llvm/Support/Regex.h:93
Parameters
- llvm::StringRef Repl
- llvm::StringRef String
- std::string* Error = nullptr
- If non-null, any errors in the substitution (invalid backreferences, trailing backslashes) will be recorded as a non-empty string. If there is no error, it will be an empty string.
¶~Regex()
~Regex()
Declared at: llvm/include/llvm/Support/Regex.h:58