帮助中心帮助中心
本页采用了机器翻译。点击此处可查看英文原文。
提取 Requirements Table模块中位置之前的子字符串
自 R2022b 起
newStr = extractBefore(str,subStr)
newStr = extractBefore(str,pos)
示例
newStr = extractBefore(str,subStr) 返回 str 中在子字符串 subStr 第一次出现之前结束的子字符串。
newStr
str
subStr
newStr = extractBefore(str,pos) 返回 str 在字符位置 pos 之前结束的子字符串。
pos
全部展开
在 Requirements Table模块中,创建一个需求,提取子字符串 "," 之前的字符串 "Hello, world!" 中的字符。输出为 "Hello"。
","
"Hello, world!"
"Hello"
y = extractBefore("Hello, world!",",")
在 Requirements Table模块中,创建一个需求,提取字符串 "Hello, world!" 中第六个字符之前的字符。输出为 "Hello"。
y = extractBefore("Hello, world!",6)
输入字符串,指定为字符串标量。将文字字符串用双引号引起来。
示例: "Hello"
数据类型: string
string
substr
子字符串,指定为字符串标量。将文字字符串用双引号引起来。
字符位置,指定为正整数。
数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
single
double
int8
int16
int32
int64
uint8
uint16
uint32
uint64
输出字符串,以字符串标量形式返回。
该运算符不支持使用Simulink.Bus对象字段。
Simulink.Bus
在 R2022b 中推出
extractAfter | insertBefore
extractAfter
insertBefore
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office