No need for a regex -- all you have to do is scan until the first non-letter. Here's one way (note my std::string manipulation skills are a little rusty):
str.substr(0, std::distance(str.begin(), std::find_if_not(str.begin(), str.end(), isLetter));
Alternatively, you could use a regex like this:
([A-Za-z_][A-Za-z0-9_]*)