2 回答

TA貢獻1757條經(jīng)驗 獲得超7個贊
regexp匹配正則表達式。[startIndex,endIndex]= regexp(str,expression),其中str是輸入的字符串expression是正則表達式,返回值為子串的開始和結束下標。如果expression是普通的字符串,就變成了查找子串的下標;如果expression是正則表達式,就查找滿足正則表達式的子串的下標。
舉例:
>> [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貢獻1854條經(jīng)驗 獲得超8個贊
> 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 關注
- 1058 瀏覽
添加回答
舉報