regex - Matching specific lengths with regexp in Matlab -
string matching question in matlab. if have matrix
a = ['thehe']; str = {'the','he'}; match = regexp(a,str); the output match =
[1] [1x2 double] because found 'he' twice , 'the' once how can make looks left right of string , matches 'the' once , 'he' once?
to answer explicit question, the documentation regexp can specify once search option:
a = 'thehe'; str = {'the','he'}; match = regexp(a,str, 'once'); which returns:
match = [1] [2] where match 1x2 cell array cell value(s) correspond first index of match in a each cell of str.
Comments
Post a Comment