insertAfter

Inserts text right after a marker or a position.

Category: Language Fundamentals > Data Types

Syntax

newStr = insertAfter(str, pat, new)

Inserts new after each occurrence of pat.

newStr = insertAfter(str, pos, new)

Inserts new after character position pos.

Description

The original characters are kept; only new ones are added. With a marker, the insertion is made after every match, not only the first.

Input arguments

str
Text to modify.
pat
Marker text or pattern.
pos
Position after which to insert.
new
Text to insert.

Output arguments

newStr
Text with the insertion made.

Example

Inserting after a marker

insertAfter("abcdef", "cd", "XX")
Output
ans = "abcdXXef"

See also

insertBefore extractAfter replace eraseBetween strcat