Builds a regular expression object from a simple string pattern.
A string pattern can use the following special characters:
*
"foo*"
"foo"
?
"foo?"
\
\*
This is a replacement function for ct/_string.stringPatternToRegExp.
ct/_string.stringPatternToRegExp
a simple string pattern conforming to the rules above
whether the regular expression should be case insensitive (false by default)
A regular expression implementing the pattern
import { createRegexFromPattern } from "apprt-core/string-pattern";const regex = createRegexFromPattern("foo*");const match = regex.test("foobar"); // true Copy
import { createRegexFromPattern } from "apprt-core/string-pattern";const regex = createRegexFromPattern("foo*");const match = regex.test("foobar"); // true
Builds a regular expression object from a simple string pattern.
A string pattern can use the following special characters:
*
to match any number of characters:"foo*"
will match all strings starting with"foo"
?
to match a single character:"foo?"
will match all strings of 4 characters that start with"foo"
\
to escape a special character:\*
will be interpreted as*
, and\
will be interpreted as ``This is a replacement function for
ct/_string.stringPatternToRegExp
.