jPaq Docs - RegExp.fromWildExp()

Quick Stats

Target Platforms:  PC (JScript) and the web (JavaScript)
Download Count:  1034

Summary

Generates a regular expression from the given wildcard string.

Parameters

  1. pat => String

    A string that may contain wildcard characters, which will later be used to test another string:

    • To match zero or more characters either "*" or "%" may be used.
    • To match a single digit "#" may be used.
    • To match a character with special meaning, you must precede it with "~". The "~" also serves as the escape character.
    • To match one of a specific list of characters, you may surround the character with square brackets.
    • To match any character but what is in the list, you must place a "!" after the opening square bracket ("[").
    • Use the "<" symbol to indicate the start of a word and the ">" symbol to indicate the end of one.

  2. [opts] => String

    Optional. The string of characters, each representing a single option:

    • "a" specifies that the pattern must match the entire string.
    • "b" specifies that the pattern must match the beginning of the string.
    • "e" specifies that the pattern must match the end of the string.
    • "g" specifies that the expression will be used to match every part of the string that matches the pattern.
    • "i" specifies that letter casing will be ignored.
    • "l" causes the expression to match the longest strings possible.
    • "m" changes the meaning of using the "a", "b", and "e" options so that the endpoints will pertain to lines instead of the entire string.
    • "o" causes the curly braces to represent how many times the preceeding character or group may appear.
    • "p" causes parentheses to serve a grouping indicators.

Returns

RegExp
A regular expression, equivalent to the specified wildcard string.

Related Examples

  1. Wildcard Expression Tester
    Many people know how to write wildcard searches (or wildcard expressions), but a lot less people know how to write regular expressions.  If you…