regex - How can I create an acronym from a string in MATLAB? -


Is there an easy way to create a short word from a string in MATLAB? For example:

  'Superior Temporal Gyurus' = & gt; Text after "STG"  

You want to put every capital letter in a short name .. .

... You can use the function:

  str = 'Superior temporal guerus'; % # Sample string abbr = str (regexp (str, '[A-Z]')); Get the capitalization on% #  

... or you can work and use:

  abbr = str ((str == upper (STR); & amp; amp; ~ isspace (str)); Compare the #% stroke to its uppercase% # version and keep the matching account elements ignoring% white #% # or you can use capital letters instead:  < Pre>  abbr = str ((str & lt; = 90) & amp; (str> = 65)); % Big letters go one (65) to z (90)  


Every letter that you start a word in a short name Want to put it ..

... You can use the function:

  abbr = str (regexp (str, '\ w +')); Get the letter from starting% of every word  

... or you could not use functions:

  str = strtrim (STR ); % # Trim head and trailing whitespace first abb = str ([1 search (issuer (str)) 1)); Get the first element of the string and every% # element after <# code  

... or you can modify the call to avoid the following:

  str = strtrim (str); % # Is still trim the empty space Abb = Str (transd space (string));  


If you want to introduce each capital letter to a word in a short name ...

... You can use the function:

  abbr = str (regexp (str, '\ & lt; [az] \ w *'));  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -