JXtension - String.replace$(target, replacement)

Purpose:
Provide the user the capability to simply use JavaScript's built-in version of the replace function.

Parameters:

target The string or regular expression used to find the substring that you would like to be replaced.
replacement The string that will be replacing the substring which matched target.

Returns:
The string with the specified target replaced.  If target is a string, the return value will have it replaced with replacement one time at most.  If target is a regular expression, the return value will have the target substring replaced as many times is specified by the regular expression flags.

Example #1:
The code below will show you how to search for one occurrence of a substring:

 

Example #2:
The code below will show you how to use a regular expression to replace multiple instances of the space character with " ":

 

See also: