Today I encountered an unusual error in my application. I tested it like 2 hours and did not find a solution. Maybe you can help me solve this problem. So here it is:
#include <iostream> #include <regex> #include <vector> int main() { std::regex reg("rmvb|avi|rm|mp4|256"); std::vector<std::string> ext{"rmvb", "avi", "rm", "mp4", "256", "null"}; for (int i = 0; i < 6; i++) { std::cout << ext[i] << "\t" << std::boolalpha << std::regex_match(ext[i], reg) << std::endl; } return 0; }
Output:
rmvb true avi true rm false mp4 false 256 false null false
It seems that the pattern is discarded after the second element - no matter what order I choose (I tried to change them because I thought that the numbers could cause this error, but it is not). Now I have no idea what is going on.
I am using gcc version 4.6.3 (Debian 4.6.3-1).
c ++ linux regex c ++ 11
Kacper banasik
source share