Use raw string literals for regular expressions where useful

This commit is contained in:
Thomas Goyne 2013-12-12 09:27:52 -08:00
parent cb0a55839d
commit be485dd4d4
4 changed files with 6 additions and 6 deletions

View file

@ -667,7 +667,7 @@ namespace Automation4 {
// Strip the location from the error message since it's redundant with
// the stack trace
boost::regex location("^\\[string \".*\"\\]:[0-9]+: ");
boost::regex location(R"(^\[string ".*"\]:[0-9]+: )");
message = regex_replace(message, location, "", boost::format_first_only);
std::vector<std::string> frames;

View file

@ -875,8 +875,8 @@ struct edit_line_paste_over : public Command {
namespace {
std::string trim_text(std::string text) {
boost::regex start("^( |\t|\\\\[nNh])+");
boost::regex end("( |\t|\\\\[nNh])+$");
boost::regex start(R"(^( | |\\[nNh])+)");
boost::regex end(R"(( | |\\[nNh])+$)");
text = regex_replace(text, start, "", boost::format_first_only);
text = regex_replace(text, end, "", boost::format_first_only);

View file

@ -67,7 +67,7 @@ std::vector<std::string> MicroDVDSubtitleFormat::GetWriteWildcards() const {
return GetReadWildcards();
}
static const boost::regex line_regex("^[\\{\\[]([0-9]+)[\\}\\]][\\{\\[]([0-9]+)[\\}\\]](.*)$");
static const boost::regex line_regex(R"(^[\{\[]([0-9]+)[\}\]][\{\[]([0-9]+)[\}\]](.*)$)");
bool MicroDVDSubtitleFormat::CanReadFile(agi::fs::path const& filename, std::string const& encoding) const {
// Return false immediately if extension is wrong

View file

@ -86,8 +86,8 @@ class SrtTagParser {
public:
SrtTagParser()
: tag_matcher("^(.*?)<(/?b|/?i|/?u|/?s|/?font)([^>]*)>(.*)$", boost::regex::icase)
, attrib_matcher("^[[:space:]]+(face|size|color)=('[^']*'|\"[^\"]*\"|[^[:space:]]+)", boost::regex::icase)
, is_quoted("^(['\"]).*\\1$")
, attrib_matcher(R"(^[[:space:]]+(face|size|color)=('[^']*'|"[^"]*"|[^[:space:]]+))", boost::regex::icase)
, is_quoted(R"(^(['"]).*\1$)")
{
tag_name_cases["b"] = TAG_BOLD_OPEN;
tag_name_cases["/b"] = TAG_BOLD_CLOSE;