Storing numeric index of alphabetic character in text string
Show older comments
How do I store the numeric index of the first alphabetic character in a text string? For example, TS1='%@3Gb6' returns Alpha1=4.
1 Comment
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?
Answers (1)
Jos (10584)
on 11 Feb 2016
ix = find(ismember(lower(TS1),'a':'z'),1,'first')
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!