map.apps Bundle APIs 4.20.0
    Preparing search index...

    Function createRegexFromPattern

    • 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.

      Parameters

      • pattern: string

        a simple string pattern conforming to the rules above

      • ignoreCase: boolean = false

        whether the regular expression should be case insensitive (false by default)

      Returns RegExp

      A regular expression implementing the pattern

      import { createRegexFromPattern } from "apprt-core/string-pattern";
      const regex = createRegexFromPattern("foo*");
      const match = regex.test("foobar"); // true