MATLAB: How to find the number of letters in a string? Just letters (A-Z, a-z)

characterstring

How can I find the number of letters in a string? Just letters (A-Z, a-z)?

Best Answer

Easiest way:
string = 'This is a string.';
NrLtrs = length(regexpi(string, '[a-zA-Z]'));
The number of letters only is returned in the ‘NrLtrs’ variable.