主要内容

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

eraseBetween

R2025b

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

自 R2022b 起

描述

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

示例

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

示例

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

示例

示例

全部展开

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

另请参阅

|