# Regex usage in TSystem::ListLibraries()

**URL:** <https://root-forum.cern.ch/t/regex-usage-in-tsystem-listlibraries/52503>\
**Category:** Newbie\
**Created:** [November 24, 2022, 12:25pm UTC](https://root-forum.cern.ch/t/regex-usage-in-tsystem-listlibraries/52503 "2022-11-24T12:25:48Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 25, 2022, 10:19am UTC](https://root-forum.cern.ch/t/regex-usage-in-tsystem-listlibraries/52503/12 "2022-11-25T10:19:20Z")

</div>

```cpp
//
// Usage example:
// root -l -q 'ListLibraries.cxx(".*libCore\\..*")'
//
#include "TString.h"
#include "TRegexp.h"
#include "TSystem.h"
#include <iostream>
void ListLibraries(const char *regexp = ".*", Bool_t wildcard = kFALSE) {
  if (!gSystem) return; // just a precaution
  if (!(regexp && regexp[0])) regexp = (wildcard ? "*" : ".*");
  TRegexp pat(regexp, wildcard);
  TString libs(gSystem->GetLibraries());
  TString tok;
  Ssiz_t from = 0, ext;
  while (libs.Tokenize(tok, from, " ")) {
    if ((tok.Index(pat, &ext) != 0) || (ext != tok.Length())) continue;
    std::cout << tok << "\n";
  }
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/regex-usage-in-tsystem-listlibraries/52503)._
