Main Content

eraseBetween

Delete substring between start and end points in Requirements Table block

Since R2022b

Description

example

newStr = eraseBetween(str,startStr,endStr) deletes the substring in str between the substrings startStr and endStr. eraseBetween does not delete startStr and endStr themselves.

example

newStr = eraseBetween(str,startPos,endPos) deletes the substring in str between the character positions startPos and endPos, including the characters at those positions.

example

newStr = eraseBetween(___,Boundaries=bounds) includes or excludes the boundaries specified in the previous syntaxes from the substring that the operator deletes. Specify bounds as "inclusive" or "exclusive".

Examples

expand all

In a Requirements Table block, create a requirement that erases the characters between "H" and "!" in the string "Hello, world!". The output is "Hello!".

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

This example shows a requirement that erases the characters between "H" and "!" in the string "Hello, world!".

In a Requirements Table block, create a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!". The output is "Hello!".

y = eraseBetween("Hello, world!",6,12)

This example shows a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!".

In a Requirements Table block, create a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!", including the bounds. The output is "Hello!".

y = eraseBetween("Hello, world!",6,12,Boundaries="inclusive")

This example shows a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!", including the bounds.

In a Requirements Table block, create a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!", excluding the bounds. The output is "Hello,d!".

y = eraseBetween("Hello, world!",6,12,Boundaries="exclusive")

This example shows a requirement that erases the characters between the sixth and twelfth characters of the string "Hello, world!", excluding the bounds.

Input Arguments

expand all

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

Example: "Hello"

Data Types: string

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

Data Types: string

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

Data Types: string

Starting character position, specified as a positive integer.

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

Ending character position, specified as a positive integer.

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

Boundary type, specified as either "inclusive" or "exclusive". When you set bounds to "inclusive", replaceBetween erases the text between and including the boundaries. When you set bounds to "exclusive", replaceBetween erases the text only between the boundaries.

Data Types: enumerated

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