Main Content

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

eraseBetween

删除 Requirements Table模块中起点和终点之间的子字符串

自 R2022b 起

描述

示例

newStr = eraseBetween(str,startStr,endStr) 删除 str 中位于子字符串 startStrendStr 之间的子字符串。 eraseBetween 不会删除 startStrendStr 本身。

示例

newStr = eraseBetween(str,startPos,endPos) 删除 str 中位于 startPosendPos 字符位置之间的子字符串,包括这些位置上的字符。

示例

newStr = eraseBetween(___,Boundaries=bounds) 在运算符删除的子字符串中包含或排除前面语法中指定的边界。将 bounds 指定为 "inclusive""exclusive"

示例

全部展开

Requirements Table模块中,创建一个需求,删除字符串 "Hello, world!""H""!" 之间的字符。输出为 "Hello!"

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

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

Requirements Table模块中,创建一个需求,删除字符串 "Hello, world!" 的第六和第十二个字符之间的字符。输出为 "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!".

Requirements Table模块中,创建一个需求,删除字符串 "Hello, world!" 的第六个字符和第十二个字符之间的字符,包括边界。输出为 "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.

Requirements Table模块中,创建一个需求,删除字符串 "Hello, world!" 的第六个字符和第十二个字符之间的字符(不包括边界)。输出为 "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.

输入参数

全部展开

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

示例: "Hello"

数据类型: string

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

数据类型: string

结束子字符串,指定为字符串标量。将文字字符串用双引号引起来。

数据类型: string

起始字符位置,指定为正整数。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

结束字符位置,指定为正整数。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

边界类型,指定为 "inclusive""exclusive"。当您将 bounds 设置为 "inclusive" 时,replaceBetween 将删除边界之间的文本。当您将 bounds 设置为 "exclusive" 时,replaceBetween 只会删除边界之间的文本。

数据类型: enumerated

输出参量

全部展开

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

限制

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

版本历史记录

在 R2022b 中推出

另请参阅

|