Main Content

insertBefore

在 Stateflow 图中的子字符串前插入字符串

自 R2021b 起

描述

示例

newStr = insertBefore(str,subStr,new) 将字符串 new 插入到字符串 str 中的子字符串 subStr 之前。insertAfter 在出现的每个 subStr 之前都插入 new

示例

newStr = insertBefore(str,pos,new)new 插入到 str 中的字符位置 pos 之前。

注意

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

示例

全部展开

插入文本以形成字符串 "Hello there, world!"

str = "Hello, world!";
newStr = insertBefore(str,","," there");

Stateflow chart that uses the insertBefore operator in a state.

插入文本以形成字符串 "Hello there, world!"

str = "Hello, world!";
newStr = insertBefore(str,6," there");

Stateflow chart that uses the insertBefore operator in a state.

输入参数

全部展开

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

示例: "Hello"

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

示例: "Hello"

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

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

示例: "Hello"

限制

版本历史记录

在 R2021b 中推出