Main Content

本页采用了机器翻译。点击此处可查看英文原文。

strip

从 Requirements Table模块中的字符串中删除前导字符和尾随字符

自 R2022b 起

描述

示例

newStr = strip(str) 从字符串 str 的开头和结尾删除连续的空格字符。在 Requirements Table模块中使用此运算符。

示例

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

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

示例

全部展开

Requirements Table模块中,创建一个删除字符串中前导和尾随空格字符的需求。

y = strip("    Hello, world!      ")

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

Requirements Table模块中,创建一个仅删除字符串中前导空格字符的需求。

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

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

Requirements Table模块中,创建一个需求,删除字符串中字符 e 的前导实例。

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

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

输入参数

全部展开

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

示例: "Hello"

数据类型: string

要剥离的字符串一侧,指定为 "left""right""both"

数据类型: string

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

数据类型: string

输出参量

全部展开

输出字符串,以字符串标量形式返回。

限制

  • 该运算符不支持使用Simulink.Bus对象字段。

版本历史记录

在 R2022b 中推出

另请参阅