Main Content

insertAfter

Insert string after substring in Requirements Table block

Since R2022b

Description

example

newStr = insertAfter(str,subStr,new) inserts the string new into the string str after the substring subStr. insertAfter inserts new after every occurrence of subStr. Use this operator in the Requirements Table block.

example

newStr = insertAfter(str,pos,new) inserts new into str after the character position pos.

Examples

expand all

In a Requirements Table block, create a requirement that inserts the substring " there" after the substring "Hello," in the string "Hello, world!". The output is "Hello there, world!".

y = insertAfter("Hello, world!","Hello"," there")

This example shows a requirement that inserts the substring " there" after the substring "Hello," in the string "Hello, world!".

In a Requirements Table block, create a requirement that inserts the substring " there" after the fifth character of the string "Hello, world!". The output is "Hello there, world!".

y = insertAfter("Hello, world!",5," there")

This example shows a requirement that inserts the substring " there" after the 5th character of the string "Hello, world!".

Input Arguments

expand all

Input string, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Data Types: string

Substring, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Data Types: string

Character position, specified as a positive integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

New substring, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Data Types: string

Output Arguments

expand all

Output string, returned as a string scalar.

Limitations

  • This operator does not support the use of Simulink.Bus object fields.

Version History

Introduced in R2022b