Function createWildcardRegex

  • Create a simple wildcard regular expression from the string value, converting any embedded wildcard '*' characters to match any character zero or more times (including folder seperators '/' or '\'), while escaping all other characters. The supported matching values are

    • '*' Matches any characters zero or more times (including folder seperators ''/' or '\')

    Parameters

    • value: string

      The value to be converted into a RegExp, if the value is not a string it will coerced to a string.

    • OptionalignoreCase: boolean

      Flag to indicate whether the regular expression should be case-sensitive, Defaults to false.

    • OptionalfullMatch: boolean

      Flag to identify whether the RegExp should be wrapped with '^' and '$' to incidate match the entire string only.

    Returns RegExp

    The new Regular Expression created from the provided value.

    0.9.0

    let regex = createWildcardRegex("Hello*");

    let matches = regex.exec("Hello");
    matches[0]; // "Hello";
    matches[1]; // ""

    let matches = regex.exec("Hello Darkness");
    matches[0]; // "Hello Darkness"
    matches[1]; // " Darkness"

    let matches = regex.exec("Darkness Hello");
    matches[0]; // "Hello"
    matches[1]; // ""

    let regex.exec("Darkness Hello.");
    matches[0]; // "Hello."
    matches[1]; // "."