# &rep(4)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

&rep, &irep, &xrep, &xirep - Replace string in string functions

## SYNOPSIS

&rep str1 str2 str3
&irep str1 str2 str3
&xrep str1 str2 str3
&xirep str1 str2 str3

## DESCRIPTION

These functions search for str2 in str1, replacing it with str3, returning the resultant string.

The functions may all be abbreviated to their three letter abbreviation (i.e. &xirep may be expressed as &xir). In all cases the first argument is completely evaluated before the second and third arguments.

&rep string search replace

Searches for the search string in the given string using a simple case sensitive exact match algorithm. Any occurrences are removed from string and replace is inserted in its place. Either of the 3 input strings can be the empty string (`""`).

&irep string search replace

&irep is identical to &rep except a case insensitive search algorithm is used.

&xrep string regex-search regex-replace

&xrep can be used to access the more powerful regular expression searching capabilities. The function is similar to &rep except it takes a regex search string and the replacement string may also refer to all or part of the matched string. See Regular Expressions for information on the regex format.

&xirep string regex-search regex-replace

&xirep is identical to &xrep except a case insensitive regex search is used.

## EXAMPLE

The following example turns a UNIX format file name (using a '`/`' to divide directories - like MicroEmacs) into an windows format name (using a '`\`'):

    set-variable #l0 &rep #l0 "/" "\\"

The following example replaces one or more white spaces in the variable with a single space, this is an easy way to remove unnecessary spaces:

    set-variable #l0 "This   is   not   so    spacey    after   xrep"
    set-variable #l0 &xrep #l0 "\\s +" " "
    ml-write #l0

## SEE ALSO

Operating Modes, Variable Functions, &sequal(4), &sin(4).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>