Main Content

strip

Remove leading and trailing characters from string in Requirements Table block

Since R2022b

Description

newStr = strip(str) removes consecutive whitespace characters from the beginning and end of the string str. Use this operator in the Requirements Table block.

example

newStr = strip(str,side) removes consecutive white space characters from the side specified by side.

example

newStr = strip(___,stripCharacter) strips the character specified by stripCharacter. You can use any of the input arguments in the previous syntaxes.

Examples

expand all

In a Requirements Table block, create a requirement that deletes the leading and trailing space characters in a string.

y = strip("    Hello, world!      ")

This example shows a requirement that deletes the leading and trailing space characters in the string " Hello, world! ".

In a Requirements Table block, create a requirement that deletes only the leading space characters in a string.

y = strip("    Hello, world!      ","left")

This example shows a requirement that deletes only the leading space characters in the string " Hello, world! ".

In a Requirements Table block, create a requirement that deletes leading instances of the character e in a string.

y = strip("eeeeeeHello, world!      ","left","e")

This example shows a requirement that deletes only the leading space characters in the string "eeeeeeHello, world! ".

Input Arguments

expand all

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

Example: "Hello"

Data Types: string

Side of string to strip, specified as "left", "right", or "both".

Data Types: string

Character to remove, specified as a string scalar.

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

See Also