<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121276>121276</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Check request: performance-construct-regex-only-once
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          denzor200
      </td>
    </tr>
</table>

<pre>
    
Construction time of a `std::regex` variable might be a bottleneck.
Thus we should never declare it as non-static block-scope variable in order to variable gets initialised only once.
```
std::regex r1("(.*)");            // OK
static std::regex r2("(.*)");     // OK
void process() {
 std::regex r3("(.*)");        // INCORRECT
    static std::regex r4("(.*)"); // OK
}
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEkt-K2zwQxZ9mfDM4yOO_ufCFN_kCH4UuLPsCsjyx1ZWlVJLTbp--2KRsumVbYxASnN-cORwZgh4tcwvlA5THRC5xcr4d2P5wnoRIeje8tiC6g7Mh-kVF7SxGPTO6M0qESoQ4QN5B3nke-TtUAq_Sa9kbxlmPU8SeUWLvYjRsWb3sQHTP0xLwG2OY3GIGtHxljwMrIz2jjigDWmfTEGXUCnvj1EsalLvwG1tbdH5gj9G9PY4cA2qro5ZGBx7QWfOKzipep0Ilbr_ofneNPgNqgAio2QF1QPvtsof8Ae8-oBPQCR8_bYTN3HsQ_R10T7g6PeDFO8UhbKo9Qv0AovsDmv_T3Y37_-fD49PTf4fnlYKIH5gsPubdG4T6-C62ZGjzYZ_vZcJtVudlQQU1TTK1osmqou9Z1XUhiiyva2ZRZdV52BdlVjWJbklQkRE1RFkjml1zLpUQjaCzaKjsCQrBs9RmZ8x13jk_JjqEhduMMqqrxMieTdh6SqSMtGMa9fC6Gi-PiW9XVdovY4BCGB1ieONEHc3W8DtZecTDxOoFPX9dOETIO7ywPzs_S6s4Vb_6nm6RpWuR0rVIyeJNO8V4CWuiW1ijjtPS75SbgU7r1NuRXrz7wioCnbZVAtDpts21pZ8BAAD__1xnByw">