aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r--src/common/util.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 7d9d7b408..f644c573c 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -919,4 +919,23 @@ std::string get_nix_version_display_string()
return {};
}
}
+
+ std::string glob_to_regex(const std::string &val)
+ {
+ std::string newval;
+
+ bool escape = false;
+ for (char c: val)
+ {
+ if (c == '*')
+ newval += escape ? "*" : ".*";
+ else if (c == '?')
+ newval += escape ? "?" : ".";
+ else if (c == '\\')
+ newval += '\\', escape = !escape;
+ else
+ newval += c;
+ }
+ return newval;
+ }
}