Escaping boost.regex literal string fragments

Is there no equivalent to http://doc.qt.io/qt-4.8/qregexp.html#escape in Boost.Regex, i.e. a way to escape all special characters so they match "literally"? There are manual solutions, like http://stackoverflow.com/questions/1252992/how-to-escape-a-string-for-use-in..., but shouldn't that be part of the API? Does C++11's std::regex, based on boost::regex, include this API? Thanks, --DD

On 13/10/2015 14:20, Dominique Devienne wrote:
Is there no equivalent to http://doc.qt.io/qt-4.8/qregexp.html#escape in Boost.Regex, i.e. a way to escape all special characters so they match "literally"?
No, can you use Perl's \Q \E construct for the same effect?
There are manual solutions, like http://stackoverflow.com/questions/1252992/how-to-escape-a-string-for-use-in..., but shouldn't that be part of the API?
Does C++11's std::regex, based on boost::regex, include this API? Thanks, --DD
No. John.

On Tue, Oct 13, 2015 at 6:10 PM, John Maddock
On 13/10/2015 14:20, Dominique Devienne wrote:
Is there no equivalent to http://doc.qt.io/qt-4.8/qregexp.html#escape in Boost.Regex, i.e. a way to escape all special characters so they match "literally"?
No, can you use Perl's \Q \E construct for the same effect?
Sounds like I could indeed. Didn't know about them. Thanks John! http://www.boost.org/doc/libs/1_58_0/libs/regex/doc/html/boost_regex/syntax/...
Does C++11's std::regex, based on boost::regex, include this API? Thanks,
--DD
No.
I'll try \Q \E using std::regex too.

On Tue, Oct 13, 2015 at 6:38 PM, Dominique Devienne
On Tue, Oct 13, 2015 at 6:10 PM, John Maddock
wrote: On 13/10/2015 14:20, Dominique Devienne wrote:
Is there no equivalent to http://doc.qt.io/qt-4.8/qregexp.html#escape in Boost.Regex, i.e. a way to escape all special characters so they match "literally"?
No, can you use Perl's \Q \E construct for the same effect?
Sounds like I could indeed. Didn't know about them. Thanks John!
Works great. Thanks again. --DD
I'll try \Q \E using std::regex too.
Apparently there's no Perl syntax in std::regex. So I used boost::regex instead. I'd have prefer std:: though. --DD
participants (2)
-
Dominique Devienne
-
John Maddock