介于两者之间
删除标记启动和末端的指标之间的子字符串
Syntax
newstr = erasebetweew(str,startStr,endStr)
newstr = erasebetween(str,startpos,endpos)
newstr =___,'Boundaries',bounds)
描述
deletes all characters fromnewStr
=str
,startStr
,Endstr
)str
that occur between the substringsstartStr
和Endstr
,但not deletestartStr
和Endstr
他们自己。介于两者之间
returns the remaining text asnewStr
。
如果str
是a string array or a cell array of character vectors, then介于两者之间
deletes characters from each element ofstr
。输出参数newStr
具有与str
。
例子
删除子字符串之间的文本
创建字符串数组。然后删除在子字符串之间发生的文本。
Create a string. Starting in R2017a, you can create strings using double quotes instead of thestring
function.
str =“快速棕狐”
str = "The quick brown fox"
Delete the text that occurs between the substrings"quick"
和“ 狐狸”
。这介于两者之间
function deletes the text but does not delete"quick"
或者“ 狐狸”
。
newstr = erasebetweew(str,"quick",“ 狐狸”)
newstr ="The quick fox"
从字符串数组的每个元素中删除子字符串。When you specify different substrings as start and end indicators, they must be contained in a string array or a cell array of character vectors that is the same size asstr
。
str = [“快速棕狐跳”;“懒狗”]
str =2x1 string array“快速棕狐跳”“懒狗”
startPos = ["quick";"the"];endPos = [“ 狐狸”;" dog"];newstr = erasebetween(str,startpos,endpos)
newstr =2x1 string array"The quick fox jumps" "over the dog"
删除开始位置和终点之间的子字符串
在指定为数字的开始和结束位置之间创建字符串数组并删除子字符串。
Create a string that contains a name. Starting in R2017a, you can create strings using double quotes instead of thestring
function.
str =“埃德加·艾伦·坡”
str = "Edgar Allen Poe"
删除子字符串。要删除中间名和空间字符之一,请指定字符串中的第六和第11位。删除的子字符串不符合第六和11个字符。
newstr = erasebetweew(str,6,11)
newstr ="Edgar Poe"
从字符串数组的每个元素中删除子字符串。当您使用数字数组指定不同的开始和结束位置时,它们必须与输入字符串数组相同。
str = [“埃德加·艾伦·坡”;"Louisa May Alcott"]
str =2x1 string array“埃德加·艾伦·坡”"Louisa May Alcott"
startspos = [6; 7];endPos = [11; 10];newstr = erasebetween(str,startspos,endpos)
newstr =2x1 string array"Edgar Poe" "Louisa Alcott"
Delete Text with Inclusive and Exclusive Boundaries
从字符串阵列中删除文本,其边界被迫包容或独家。介于两者之间
deletes the boundaries when they are inclusive.介于两者之间
在独家时,将边界作为输出字符串数组的一部分返回边界。
创建一个字符串数组。从R2017A开始,您可以使用双引号来创建字符串string
function.
str =“小|中|大”
str = "small|medium|large"
删除第六和第13个位置之间的文本,但不要在这些位置上删除字符。
newstr = erasebetweew(str,6,13,'Boundaries','独家的')
newstr =“小||大”
Delete the text between two substrings, and also the substrings themselves.
str ="The quick brown fox jumps over the lazy dog"
str = "The quick brown fox jumps over the lazy dog"
newstr = erasebetweew(str," brown","lazy",'Boundaries','inclusive')
newstr =“快狗”
删除字符矢量中位置之间的文本
创建一个字符向量并在开始和结束位置之间删除文本。
chr =“蘑菇,辣椒和洋葱”
chr ='蘑菇,辣椒和洋葱'
newchr = erasebetweew(chr,10,19)
newchr ='蘑菇和洋葱'
删除基因之间的文本。
newchr = erasebetweew(chr,'mushrooms',' 和')
newchr ='蘑菇和洋葱'
Input Arguments
str
—输入文本
字符串数组|character vector|细胞array of character vectors
输入文本,指定为字符串数组,字符向量或字符向量的单元格数组。
Data Types:string
|char
|细胞
startStr
—指示启动子字符串删除的字符串
字符串数组|character vector|细胞array of character vectors
字符串指示子字符串删除的开始,将字符串数组,字符向量或字符向量的单元格数组指定。
如果str
是a string array or a cell array of character vectors, thenstartStr
可以是字符向量,字符串标量,字符串数组或与与str
。
例子:擦除(str,“ ab”,“ yz”)之间
deletes all characters betweenAB
和Yz
在each element ofstr
。
例子:如果str
是a2
-经过-1
字符串数组,然后介于两者之间(str,["AB";"FG"],["YZ";"ST"])
deletes all characters betweenAB
和Yz
在str(1)
, 和betweenFG
和ST
在str(2)
。
Data Types:string
|char
|细胞
Endstr
—String that indicates end of substring to delete
字符串数组|character vector|细胞array of character vectors
String that indicates the end of the substring to delete, specified as a string array, a character vector, or a cell array of character vectors.
如果str
是a string array or a cell array of character vectors, thenEndstr
可以是字符向量,字符串标量,字符串数组或与与str
。
例子:擦除(str,“ ab”,“ yz”)之间
deletes all characters betweenAB
和Yz
在each element ofstr
。
例子:如果str
是a2
-经过-1
字符串数组,然后介于两者之间(str,["AB";"FG"],["YZ";"ST"])
deletes all characters betweenAB
和Yz
在str(1)
, 和betweenFG
和ST
在str(2)
。
Data Types:string
|char
|细胞
startPos
—Start position of substring to delete
numeric array
Start position of substring to delete, specified as a numeric array.
如果str
是a string array or a cell array of character vectors, thenstartPos
can be a numeric scalar or a numeric array of the same size asstr
。
例子:介于两者之间(str,5,9)
删除从第五个字符到第九位的所有字符str
。
例子:如果str
是a2
-经过-1
字符串数组,然后介于两者之间(str,[5;10],[9;21])
删除从第五到第九位的所有字符str(1)
, 和from the 10th through the 21st positions instr(2)
。
Data Types:双倍的
|single
|在t8
|INT16
|INT32
|在t64
|uint8
|UINT16
|uint32
|uint64
端台
—End position of substring to delete
numeric array
删除的基因的最终位置,指定为数字阵列。
如果str
是a string array or a cell array of character vectors, then端台
can be a numeric scalar or a numeric array of the same size asstr
。
例子:介于两者之间(str,5,9)
删除从第五个字符到第九位的所有字符str
。
例子:如果str
是a2
-经过-1
字符串数组,然后介于两者之间(str,[5;10],[9;21])
删除从第五到第九位的所有字符str(1)
, 和from the 10th through the 21st positions instr(2)
。
Data Types:双倍的
|single
|在t8
|INT16
|INT32
|在t64
|uint8
|UINT16
|uint32
|uint64
Output Arguments
newStr
— Output text
字符串数组| character vector | cell array of character vectors
Output text, returned as a string array, a character vector, or a cell array of character vectors.str
和newStr
具有相同的数据类型。
Data Types:string
|char
|细胞
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, seeTall Arrays。
C/C ++代码生成
使用MATLAB®CODER™生成C和C ++代码。
用法注释和限制:
str
,startStr
, 和Endstr
must be a string scalar, a character vector, or a cell array containing not more than one character vector.
See Also
count
|擦除
|extractAfter
|提取之前
|extractBetween
|在sertAfter
|在sertBefore
|join
|代替
|替换之间
|size
|分裂
|strlength
Introduced in R2016b
matlab命令
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
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:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)