regex - How do I edit a string in Matlab so that it only contains letters A-Z -


i need able edit string in matlab contains letters a-z.

example:

if have words

dog  cat fish °·°·°· ∞°¥È ¥©±∏≥™ ¥Î„‚Ω‚‡Ó 

i want able edit list words

dog cat fish 

currently, way editing words using regexp() shown below.

pat = '[\s\.\]\[\&\%\#\*\,\$\_\ ,;:-''"?!/()@=><]+';  words = regexp(st,pat,'split'); words = lower(words); 

this method works removing quite bit of symbols don't want there has been few exceptions, including ones listed above, want remove.

you can try:

for i=length(string):-1:1     if string[i]<int8('a') || (string[i]>int8('z') && string[i]<int8('a')) || string[i]>int8('z')         string=[string(1:i-1) string(i+1:end);     end end 

not efficient or elegant thing in world, work.

also, if don't want use loops, can like:

condition = str>='a' & str <='z'; % | ... string=string[condition]; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -