mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-12 10:13:51 +01:00
Fix format regex escape sequences
This commit is contained in:
parent
25dcdb1c3a
commit
94d3bfd39a
@ -375,7 +375,7 @@ public:
|
||||
}
|
||||
} else if (format == "time") {
|
||||
// Matches times like: 16:52:45Z, 16:52:45+02:00
|
||||
std::regex time_regex("^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
|
||||
std::regex time_regex("^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
|
||||
if (std::regex_match(s, time_regex)) {
|
||||
return true;
|
||||
} else {
|
||||
@ -387,7 +387,7 @@ public:
|
||||
}
|
||||
} else if (format == "date-time") {
|
||||
// Matches data times like: 2022-07-18T16:52:45Z, 2022-07-18T16:52:45+02:00
|
||||
std::regex datetime_regex("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
|
||||
std::regex datetime_regex("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
|
||||
std::smatch matches;
|
||||
if (std::regex_match(s, matches, datetime_regex)) {
|
||||
const auto month = std::stoi(matches[2].str());
|
||||
|
Loading…
Reference in New Issue
Block a user