Use C++ strings and handle non-capturing groups