Documentation

介于两者之间

删除标记启动和末端的指标之间的子字符串

Syntax

newstr = erasebetweew(str,startStr,endStr)
newstr = erasebetween(str,startpos,endpos)
newstr =___,'Boundaries',bounds)

描述

example

newStr=str,startStr,Endstr)deletes all characters fromstrthat occur between the substringsstartStrEndstr,但not deletestartStrEndstr他们自己。介于两者之间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

example

newStr=str,startPos,端台)deletes all characters fromstr在位置之间发生startPos端台,包括那些位置的角色。

example

newStr=___,'Boundaries',bounds)forces the starts and ends specified in any of the previous syntaxes to be either inclusive or exclusive. They are inclusive when边界'inclusive',何时独家边界'独家的'。For example,介于两者之间(str,startStr,endStr,'Boundaries','inclusive')deletesstartStr,Endstr,以及它们之间的所有文字。

例子

全部收缩

创建字符串数组。然后删除在子字符串之间发生的文本。

Create a string. Starting in R2017a, you can create strings using double quotes instead of thestringfunction.

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 thestringfunction.

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"

从字符串阵列中删除文本,其边界被迫包容或独家。介于两者之间deletes the boundaries when they are inclusive.介于两者之间在独家时,将边界作为输出字符串数组的一部分返回边界。

创建一个字符串数组。从R2017A开始,您可以使用双引号来创建字符串stringfunction.

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

全部收缩

输入文本,指定为字符串数组,字符向量或字符向量的单元格数组。

Data Types:string|char|细胞

字符串指示子字符串删除的开始,将字符串数组,字符向量或字符向量的单元格数组指定。

如果str是a string array or a cell array of character vectors, thenstartStr可以是字符向量,字符串标量,字符串数组或与与str

例子:擦除(str,“ ab”,“ yz”)之间deletes all characters betweenABYz在each element ofstr

例子:如果str是a2-经过-1字符串数组,然后介于两者之间(str,["AB";"FG"],["YZ";"ST"])deletes all characters betweenABYzstr(1), 和betweenFGSTstr(2)

Data Types:string|char|细胞

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 betweenABYz在each element ofstr

例子:如果str是a2-经过-1字符串数组,然后介于两者之间(str,["AB";"FG"],["YZ";"ST"])deletes all characters betweenABYzstr(1), 和betweenFGSTstr(2)

Data Types:string|char|细胞

Start position of substring to delete, specified as a numeric array.

如果str是a string array or a cell array of character vectors, thenstartPoscan 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

删除的基因的最终位置,指定为数字阵列。

如果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

全部收缩

Output text, returned as a string array, a character vector, or a cell array of character vectors.strnewStr具有相同的数据类型。

Data Types:string|char|细胞

Extended Capabilities

Introduced in R2016b

这个话题有帮助吗?