-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!regexmeow is a substring of homeownermeow is a substring of homeowner
Description
Describe the bug
In the following code snippet, the second regex capture called callConv fails to be captured. Instead the group is set to 'false'. This behavior does not occur on clang or GCC.
#include <iostream>
#include <regex>
int main()
{
std::regex fnTypeDefRgx("([a-zA-Z_][a-zA-Z0-9_*]*)\\s*(?:([a-zA-Z_][a-zA-Z0-9_*]*)?\\s*)?(?:[a-zA-Z_][a-zA-Z0-9_]*)?\\s*\\((.*)\\)");
std::smatch matches;
std::string input = "void stdcall (char*, float, uint8_t)";
if (std::regex_search(input, matches, fnTypeDefRgx)) {
std::string retType = matches[1].str();
std::string callConv = matches[2].str(); // this guy is 'false' BUG
std::cout << callConv << std::endl;
}
return 0;
}
for convenience, the unespaced regex is as follows. It regexs the return value, optional calling convention, and then parameters all as one with optional *'s on the type names.
([a-zA-Z_][a-zA-Z0-9_*]*)\s*(?:([a-zA-Z_][a-zA-Z0-9_*]*)?\s*)?(?:[a-zA-Z_][a-zA-Z0-9_]*)?\s*\((.*)\)
Expected behavior
The expected output would be that the second capture group contains the string 'stdcall' as in the online compiler here: https://onlinegdb.com/ry28UXodI
STL version
Microsoft Visual Studio Community 2019 Version 16.4.5
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!regexmeow is a substring of homeownermeow is a substring of homeowner