jPaq Docs - String.prototype.replacePattern()

Quick Stats

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


Find one or more occurrences which match the specified wildcard expression and replace it with another string or expression.


  1. pat => String
    The wildcard expression used to find the starting position of one or more matching substrings.
  2. opts => String
    A string of characters, each representing an option. If no options are needed, pass null.
  3. rep => Object
    This may be either a string or a callback function. This serves the same purpose as the second parameter of String.prototype.replace(...).


If the "g" option is supplied, all of the found occurrences will be replaced. If the "g" flag isn't supplied, only replace the first occurrence with the replacement expression.

Related Examples

  1. Finding & Replacing with Wildcards
    The following shows you how to search strings by using wildcards and even how to replace what you find: alert("Where in the world is…