2 回答

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
regexp匹配正則表達(dá)式。[startIndex,endIndex]= regexp(str,expression),其中str是輸入的字符串expression是正則表達(dá)式,返回值為子串的開始和結(jié)束下標(biāo)。如果expression是普通的字符串,就變成了查找子串的下標(biāo);如果expression是正則表達(dá)式,就查找滿足正則表達(dá)式的子串的下標(biāo)。
舉例:
>> [startIndex,endIndex]= regexp('hello world','or')
startIndex =
8
endIndex =
9
>> [startIndex,endIndex]= regexp('hello world',' ')
startIndex =
6
endIndex =
6
>> str = 'bat cat can car coat court CUT ct CAT-scan';
expression = 'c[aeiou]+t';
startIndex = regexp(str,expression)
startIndex =
5 17

TA貢獻(xiàn)1854條經(jīng)驗(yàn) 獲得超8個(gè)贊
> str2num(a{1,2})
ans =
34353500
>> a{1,2}
ans =
343535E+02
>> str2num(a{1,3})
ans =
342.3330
>> a{1,3}
ans =
342.333
- 2 回答
- 0 關(guān)注
- 1065 瀏覽
添加回答
舉報(bào)