FreeBSD Bugzilla – Attachment 200092 Details for
Bug 233994
boost::regex match but not std::regex
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Testcase
bug.cpp (text/plain), 1.78 KB, created by
georg-bsd
on 2018-12-13 21:18:28 UTC
(
hide
)
Description:
Testcase
Filename:
MIME Type:
Creator:
georg-bsd
Created:
2018-12-13 21:18:28 UTC
Size:
1.78 KB
patch
obsolete
>// build with >// clang --std=c++17 bug.cpp -O0 -g -I /usr/local/include -lc++ -L/usr/local/lib/ -lboost_locale >// freebsd-version 11.2-RELEASE-p1 >// clang FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0) > >#include <regex> >#include <string> >#include <iostream> >#include <sstream> > >#include <boost/locale.hpp> > >int main(int argc, char** argv) >{ > // Set global localization backend > using namespace boost::locale; > localization_backend_manager my = localization_backend_manager::global(); > my.select("icu"); > localization_backend_manager::global(my); > > boost::locale::generator gen; > std::locale loc{ gen("de_DE.UTF-8") }; > std::locale::global(loc); > > std::string test {{ > "Author: aaa\n" > "Ti: test\n" > "S: test\n" > "Date: 2018-12-09 14:40:27\n" > "T1: test\n"}}; > > std::regex re_author("^Author\\s*:[\\s\\t]*(.*?)$", > std::regex_constants::icase); > std::regex re_title("^Title\\s*:[\\s\\t]*(.*?)$", > std::regex_constants::icase); > std::regex re_slug("^Slug\\s*:[\\s\\t]*(.*?)$", > std::regex_constants::icase); > std::regex re_datetime("^Date\\s*:[\\s\\t]*(\\d{4}\\-\\d{2}\\-\\d{2} " > "\\d{2}:\\d{2}:\\d{2}?)$", > std::regex_constants::icase); > > std::string line; > std::istringstream iss(test); > std::smatch match; > > bool ok = false; > while (std::getline(iss, line)) > { > if (regex_match(line, match, re_author) && match.size() > 1) > { > // do stuff > } > else if (regex_match(line, match, re_title) && match.size() > 1) > { > // do stuff > } > else if (regex_match(line, match, re_slug) && match.size() > 1) > { > // do stuff > } > else if (std::regex_match(line, match, re_datetime) && match.size() > 1) > { > ok = true; > } > } > > if (ok) > { > std::cout << "All ok" << std::endl; > } > else > { > std::cout << "Bug triggered" << std::endl; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 233994
: 200092 |
200200