Functions

trReplaceAll

Supported By

Syntax

[the] trReplaceAll of ( haystack , needle , noodle )

[the] trReplaceAll of ( haystack , options , needle )

[the] trReplaceAll of ( haystack , options , needle , noodle )

trReplaceAll ( haystack , needle , noodle )

trReplaceAll ( haystack , options , needle )

trReplaceAll ( haystack , options , needle , noodle )

Haystack yields any string. Options yields a string starting with a hyphen. Needle and noodle yields strings describing sets of characters.

Description

In its basic form, the trReplaceAll function returns the string haystack with every occurrence of any of the characters in needle replaced with the corresponding character in noodle.

If options contains s but not d, then noodle is optional. If noodle is specified, every occurrence of any of the characters in needle is replaced with the corresponding character in noodle, then multiple consecutive occurrences of any one character in noodle are replaced with a single occurrence. If noodle is not specified, multiple consecutive occurrences of any one character in needle are replaced with a single occurrence.

If options contains d but not s, only needle must be specified. Every occurrence of any character in needle is removed from haystack.

If options contains both d and s, both needle and noodle must be specified. Every occurrence of any character in needle is removed from haystack. Multiple consecutive occurrences of any one character in noodle are replaced with a single occurrence.

If options contains the character c, the complement of needle is taken, so that characters not in needle will be matched instead.

Needle and noodle describe sets of characters, not strings. A range of characters can be specified by putting a hyphen between two characters; to match a literal hyphen, put a hyphen at the beginning or end. For example, the following pattern matches all numbers and basic Latin letters, as well as hyphens: A-Za-z0-9-

See Also

trReplace, replaceAll, csReplaceAll, regReplaceAll