Matlab string processing function summary

% String processing 
a=' a'; b='b b'; c='cccc'; m='' 
% Get the string length 
length (a)     
% Connect two strings, the rightmost of each string Spaces are cut 
d= strcat (a,c)  
length(d) 
% Connect multiple lines of strings, each line can be of different lengths, and automatically add spaces to the right of the non-longest string 
% to make it equal to the longest string. Ignore the empty string 
e= strvcat (a,b,m) 
size(e) 
% char connection, the empty string will be filled with spaces 
f= char (a,b,m) 
size(f)

strcmp     compares whether two strings are completely equal, yes, returns true, otherwise, returns false 
strncmp compares     whether the first n characters of the two strings are equal, yes, returns true, otherwise, returns false 
strcm pi compares two characters Whether the strings are completely equal, ignoring letter case 
strncmpi    compares whether the first n characters of two strings are equal, ignoring letter case

isletter   detects whether each character in a string belongs to an English letter 
isspace     detects whether each character in a string belongs to a format character (space, carriage return, tab, newline, etc.) 
isstrprop   detects whether each character in a character belongs to the specified The range of 
a='d sdsdsd 15#'; 
b=isletter(a) 
c=isspace(a)

% String replacement and search   
strrep  performs string replacement, case sensitive 
% strrep(str1,str2,str3) 
% It replaces all str2 strings in str1 with str3

strfind (str,patten) finds whether there is a pattern in str, returns the position where it appears, and returns an empty array if it does not appear 
findstr (str1,str2) finds the position where the shorter string appears in the longer string in str1 and str2, Return an empty array if there is no occurrence 
strmatch (patten,str) Check whether patten is consistent with the leftmost part of str 
strtok (str,char) Return the part before and after the string specified by char in str, 
mm='youqwelcome '; 
[mm1,mm2]=strtok(mm,'q')

Blanks (n) with n spaces created string composed 
deblank trailing spaces (str) cutting string 
strtrim spaces at the beginning and tail (str) cutting string, tabs, carriage returns,

lower (str) converts the letters in the string to lowercase 
upper (str) converts the letters in the string to uppercase  
sort (str) sorts the string according to the ASCII value of the character

num2str          converts a number into a numeric string 
str2num           converts a numeric string into a number 
mat2str           converts an array into a string 
int2str           converts a numeric array into a character array of integer numbers

------------------------------

String comparison in the CELL array:

c=cell(2,1); 
c(1,1)=cellstr('xxx'); 
c(2,1)=cellstr('yyyyyyy'); 
strcmp(c{1,1},c{2,1});

------------------------------

isequal    Test arrays for equality, can be used to compare whether two character arrays are the same.

Guess you like

Origin blog.csdn.net/Dust_Evc/article/details/111308453