[Mlir-commits] [mlir] [MLIR][Python] Remove partial LLVM APIs in python bindings (5/n) (PR #180644)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Feb 9 15:58:14 PST 2026
================
@@ -22,6 +24,21 @@
namespace nb = nanobind;
using namespace mlir;
+/// Local helper adapted from llvm::Regex::escape.
+namespace {
+static const char RegexMetachars[] = "()^$|*+?.[]\\{}";
+
+static std::string escapeRegex(std::string_view String) {
+ std::string RegexStr;
+ for (char C : String) {
+ if (std::strchr(RegexMetachars, C))
+ RegexStr += '\\';
+ RegexStr += C;
+ }
+ return RegexStr;
+}
+} // namespace
----------------
kuhar wrote:
Let's inline the string since it's not used anywhere else
```suggestion
static std::string escapeRegex(std::string_view String) {
static constexpt char RegexMetachars[] = "()^$|*+?.[]\\{}";
std::string RegexStr;
for (char C : String) {
if (std::strchr(RegexMetachars, C))
RegexStr += '\\';
RegexStr += C;
}
return RegexStr;
}
```
https://github.com/llvm/llvm-project/pull/180644
More information about the Mlir-commits
mailing list