Main Content

extractAfter

Extract substring after position

Description

example

newStr = extractAfter(str,subStr) returns the substring of str that begins after the last occurrence of the substring subStr.

example

newStr = extractAfter(str,pos) returns the substring of str that begins after the character position pos.

Examples

expand all

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

y = extractAfter("Hello, world!","Hello, ")

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

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

y = extractAfter("Hello, world!",7)

This example shows a requirement that extracts the substring after the 7th character in 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

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