Template:Str rep/doc

Returns a modified copy of a given text, with the first occurrence of a find-string replaced with a replacement-string.

Usage
This is equivalent to.

Parameters
There are three positional (unnamed) parameters, all required:
 * 1) the initial text string subject to search and replacement
 * 2) the find-string to search for in the text
 * 3) the replacement string: param 3 replaces param 2's first occurrence in param 1.

Details
The value of the text parameter may be anything that resolves to a string, such as:
 * Immediate text entered directly into the parameter field:
 * A parameter passed from a transcluding template: or
 * A file or template:
 * or anything else that resolves to a string.

Equal signs and pipes
Equal signs in parameter values passed as immediate text either need to be escaped as, or you can leave them unescaped and use the built-in numeric names (1, 2, and 3) for the three unnamed positional parameters, as in the section usage at the top.

Pipe characters in immediate text should be escaped either as  or as !. See Help:Template. Pipe characters in embedded items such as params or template invocations don't need to be escaped.

White space
Pay attention to the use of white space in the parameters; all white space is significant in positional parameters. In particular, leading and trailing white space is not removed, and can affect the results. See contrasting examples #1 and #2 below.

If you like the readability of having convenience blanks before and after the parameters so they're not adjacent to the pipe characters, then use the built-in numeric names 1, etc. These will not include any leading or trailing blanks in the parameter value; see example 3.

Examples

 * 1)   ⟶ Dogs chase balls.
 * 2)   ⟶ Dogs chase balls.     &mdash; ❌ leading and trailing blanks are significant; see Details
 * 3)   ⟶ Dogs chase cats.     &mdash; ✅ ... but not when named parameters are used
 * 4)   ⟶ Dogs love cats. Cats chase mice.     &mdash; only first occurrence replaced
 * 5)   ⟶      &mdash; text can be entered by a template