I'm trying to use a captured group directly in the regex. However, when I try to do this the program hangs indefinitely.
For example:
string input = "<Tag>blahblah</Tag>";
regex r1("<([a-zA-Z]+)>[a-z]+</\1>");
string result = regex_replace(result, regex, "");
If I add another slash to the capture "<([a-zA-Z]+)>[a-z]</\\1>"
, the program compiles but throws a "regex_error(regex_constants::error_backref)" exception.
Notes:
Compiler: Apple LLVM 5.1
I am using this as part of the process to clean junk from blocks of text. The document is not necessarily HTML/XML and desired text is not always within tags. So if possible, I would like to be able to do this with regular expressions, not a parser.