Announce

PukiWiki contents have been moved into SONOTS Plugin (20070703)

Matlab String Operations and Functions

Table of Contents

Comparison Table

phpmatlab
'a' . 'b'['a' 'b'], strcat('a', 'b')
array('a','b')['a';'b'], strvcat('a','b') (two dimensional array), or {'a','b'} (cell array)
substr($str, 0, 3)str(1:2), subtr(str, 0, 3) (MATLB String Utilities)
rtrim($str)deblank(str)
trim($str)strtrim(str)
explode($delim,$str) (split)strsplit(delim,str) (MATLB String Utilities)
implode($delim,$str) (join)strjoin(delim,str) (MATLB String Utilities)
strpos($str,$needle)strfind(str,needle), findstr(str,needle), findstr(needle,str)
preg($regexp,$str), ereg($regexp,$str)regexp(str,regexp)
pregi($regexp,$str), eregi($regexp,$str)regexpi(str,regexp)
preg_replace($pattern,$replace,$str), ereg_replace($pattern,$replace,$str)regexprep(str,pattern,replace)
preg_grep($pattern,$array)
strlen($str)length(str)
str_replace($pattern,$replace,$str)strrep(str,pattern,replace)
sprintfsprintf
sscanfsscanf
strtok($str,$token)strtok(str,token)
strcmp($str1,$str2)strcmp(str1,str2)
strncmp($str1,$str2,$len)strncmp(str1,str2,len)
strcasecmp($str1,$str2)strcmpi(str1,str2)
strtolower($str)lower(str)
strtoupper($str)upper(str)
ucfirst($str)[upper(str(1)), str(2:end)]
lcfirst($str)[lower(str(1)), str(2:end)]
ucwords($str)
genvarname(str)
parse_url($str) (This is for URL, though)[dir,file,ext]=fileparts(str)
http_build_query (This is for URL, though)fullfile(dir,file)

References