'Difficulty using boost::regex_match to get separate matches for "NASIONAL" and "12" from string "NASIONAL12"

This works fine in all online regex testers but fails to produce any matches in boost::regex_match, which I unfortunately must use as is because it is being used in a system that expects this format for more complicated parsings of street names.

std::string rformat = "(([a-zA-Z]*)|([0-9]*))?";
std::string source = "NASIONAL12";
const boost::regex piecesRegex(rformat);
boost::smatch      piecesMatch;
if (boost::regex_match(source, piecesMatch, piecesRegex))
{
   for (auto match : piecesMatch) {
       std::cerr << "MATCH:" << match << std::endl;
   }
}

What I need is for the first "piecesMatch" to return "NASIONAL" and the second "piecesMatch" to return "12"



Solution 1:[1]

Thanks to everyone's help I found the right regex string:

([a-zA-Z]*)?([0-9]*)?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1