Main Content

strip

从 Stateflow 图中的字符串删除前导和尾随字符

自 R2021b 起

描述

示例

newStr = strip(str) 从字符串 str 的开头和末尾删除连续空白字符。

示例

newStr = strip(str,side)side 指定的一侧删除连续空白字符。

newStr = strip(___,stripCharacter) 去除由 stripCharacter 指定的字符。您可以使用上述语法中的任何输入参量。

注意

使用 C 语言作为动作语言的 Stateflow® 图不支持 strip 运算符。

示例

全部展开

删除前导和尾随空格并返回字符串 "Hello, world!"

str = "    Hello, world!      ";
newStr = strip(str);

Stateflow chart that uses the strip operator in a state.

删除前导空格并返回字符串 "Hello, world! "

str = "    Hello, world!    ";
str1 = strip(h,"left");

Stateflow chart that uses the strip operator in a state.

删除尾随空格并返回字符串 " Hello, world!"

str = "    Hello, world!    ";
str1 = strip(h,"right");

Stateflow chart that uses the strip operator in a state.

删除前导和尾随连字符并返回字符串 "Hello, world!"

str = "----Hello, world!----";
newStr = strip(str);

Stateflow chart that uses the strip operator in a state.

输入参数

全部展开

输入字符串,指定为字符串标量。用双引号将文字字符串引起来。

示例: "Hello"

要去除的字符串的一侧,指定为 "left""right""both"

要删除的字符,指定为字符串标量。

限制

版本历史记录

在 R2021b 中推出