str-to-regex(3)str-to-regex - Generate regex safe variant of a string
filemask-to-regex - Convert a file mask to a regex
str-to-regex "in-out-var"
filemask-to-regex "in-out-var"
str-to-regex converts a given string to a regex-safe variant so that it can be used as part of a regex search. Regular expressions use several special characters, such as '.', '*', '[' and str-to-regex inserts a '\' quote character to make it a literal string. For example "A.B*C\" will be converted to "A\.B\*C\\".
filemask-to-regex converts a typical file mask, used by command-line tools in a console, to a regex. This typically involves the conversion of '?' to '.', '*' to '.*' and the quoting of other regular expression special characters, such as '.' to '\.'.
Both of these macros take a single argument, in-out-var, which must be the name of a variable. The initial value of this variable is used as the string to be converted and on completion the value of the variable is updated to the output regex string.
The str-to-regex and filemask-to-regex commands are implemented in utils.emf and are not publically available from the command line, but may be used within macros.
(c) Copyright JASSPA 2025
Last Modified: 2025/12/01
Generated On: 2025/12/01