aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-02-17 20:08:42 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-02-17 20:08:42 +0000
commitd2a5c0d8562407f9acab97451a785b513edd4c9b (patch)
tree0ceb19ccf4414d45f6c514e20dbe3db6a7d5d719 /include
parentb886089645a144babe64067928acc19814434775 (diff)
downloadexternal_llvm-d2a5c0d8562407f9acab97451a785b513edd4c9b.zip
external_llvm-d2a5c0d8562407f9acab97451a785b513edd4c9b.tar.gz
external_llvm-d2a5c0d8562407f9acab97451a785b513edd4c9b.tar.bz2
Add Regex::sub, for doing regular expression substitution with backreferences.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/Regex.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/llvm/Support/Regex.h b/include/llvm/Support/Regex.h
index c954c0d..591af00 100644
--- a/include/llvm/Support/Regex.h
+++ b/include/llvm/Support/Regex.h
@@ -56,6 +56,19 @@ namespace llvm {
///
/// This returns true on a successful match.
bool match(const StringRef &String, SmallVectorImpl<StringRef> *Matches=0);
+
+ /// sub - Return the result of replacing the first match of the regex in
+ /// \arg String with the \arg 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).
+ ///
+ /// \param Error If non-null, any errors in the substitution (invalid
+ /// backreferences, trailing backslashes) will be recorded as a non-empty
+ /// string.
+ std::string sub(StringRef Repl, StringRef String, std::string *Error = 0);
+
private:
struct llvm_regex *preg;
int error;