Storing numeric index of alphabetic character in text string
Ältere Kommentare anzeigen
How do I store the numeric index of the first alphabetic character in a text string? For example, TS1='%@3Gb6' returns Alpha1=4.
1 Kommentar
Here are two simple methods to get the indices of the alphabetic characters:
>> TS1 = '%@3Gb6';
>> regexp(TS1,'[A-Za-z]','once') % only the first
ans = 4
>> find(isstrprop(TS1,'alpha')) % all alphabetic
ans =
4 5
What do you want to do with the indices?
Antworten (1)
Jos (10584)
am 11 Feb. 2016
ix = find(ismember(lower(TS1),'a':'z'),1,'first')
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!