This whole `if` block is pretty awkward, really. I think you can rewrite it to be a lot simpler (and more correct!) to something like:

    nondash = curName.find_first_not_of("-");
    if (nondash == 0 || nondash == npos || isdigit(curName[nondash])) withNoKey = true;
    else curName.erase(0, nondash);

(pseudocode; not compiled or tested :wink:)