- std::smatch match;
- if (std::regex_search(map_basename, match, so_re)) {
- libname = match.prefix();
-
- // Strip the version suffix:
- if (std::regex_search(libname, match, version_re))
- libname = match.prefix();
+ size_t pos = map_basename.rfind(".so");
+ if (pos != std::string::npos) {
+ // strip the extension (matching regex "\.so.*$")
+ libname.assign(map_basename, 0, pos);
+
+ // strip the version suffix (matching regex "-[.0-9-]*$")
+ while (true) {
+ pos = libname.rfind('-');
+ if (pos == std::string::npos || libname.find_first_not_of(".0123456789", pos + 1) != std::string::npos)
+ break;
+ libname.erase(pos);
+ }