- •127 Codes are ascii). The actual characters displayed depends on the
- •String operations
- •In expression, patterns are specified using combinations of metacharacters
- •In expression, patterns are specified using combinations of metacharacters
- •In arrays s1, s2, ..., sn. Inputs can be combinations of single
- •Is the same size as c1 or c2, and contains logical 1 (true) for those
- •Input c is a cell array of strings. The function returns tf, a logical
- •Is the same size as c1 or c2, and contains logical 1 (true) for those
- •Input c is a cell array of strings. The function returns tf, a logical
- •Version of the character array s.
- •Input parameters:
- •Character set conversion
- •Is unspecified or is the empty string (''), matlab's default
- •If you apply an integer or string conversion to a numeric value that
- •Xregtable/sprintf
- •Base number conversion
- •If s is a character array, each row is interpreted as a base b string.
Input c is a cell array of strings. The function returns tf, a logical
array that is the same size as C and contains logical 1 (true) for those
elements of C that are a match, except for letter case, and logical 0
(false) for those elements that are not. The order of the two input
arguments is not important.
TF = STRNCMPI(C1,C2,N) performs a case-insensitive comparison between
the first N characters of each element of cell array C1 and the first N
characters of the same element in cell array C2. Inputs C1 and C2 are
equal-size cell arrays of strings. Input C1 and/or C2 can also be a
character array having the same number of rows as there are cells in the
cell array. The function returns TF, a logical array that is the same size
as C1 or C2, and contains logical 1 (true) for those elements of C1 and C2
that are a match, except for letter case, and logical 0 (false) for those
elements that are not.
When one of the inputs is a cell array, scalar expansion will occur as
needed.
STRNCMPI supports international character sets.
See also strcmp, strncmp, strcmpi, regexpi.
Overloaded methods:
opaque/strncmpi
Reference page in Help browser
doc strncmpi
<strfind> - Find one string within another.
STRFIND Find one string within another.
K = STRFIND(TEXT,PATTERN) returns the starting indices of any
occurrences of the string PATTERN in the string TEXT.
STRFIND will always return [] if PATTERN is longer than TEXT.
Examples
s = 'How much wood would a woodchuck chuck?';
strfind(s,'a') returns 21
strfind('a',s) returns []
strfind(s,'wood') returns [10 23]
strfind(s,'Wood') returns []
strfind(s,' ') returns [4 9 14 20 22 32]
See also strcmp, strncmp, regexp.
Overloaded methods:
cell/strfind
Reference page in Help browser
doc strfind
<strjust> - Justify character array.
STRJUST Justify character array.
T = STRJUST(S) or T = STRJUST(S,'right') returns a right justified
Version of the character array s.
T = STRJUST(S,'left') returns a left justified version of S.
T = STRJUST(S,'center') returns a center justified version of S.
See also deblank, strtrim.
Overloaded methods:
cell/strjust
Reference page in Help browser
doc strjust
<strrep> - Replace string with another.
STRREP Replace string with another.
MODIFIEDSTR = STRREP(ORIGSTR,OLDSUBSTR,NEWSUBSTR) replaces all
occurrences of the string OLDSUBSTR within string ORIGSTR with the
string NEWSUBSTR.
Notes:
* STRREP accepts input combinations of single strings, strings in
scalar cells, and same-sized cell arrays of strings. If any inputs
are cell arrays, STRREP returns a cell array.
* STRREP does not find empty strings for replacement. That is, when
ORIGSTR and OLDSUBSTR both contain the empty string (''), STRREP does
not replace '' with the contents of NEWSUBSTR.
Examples:
% Example 1: Replace text in a character array.
claim = 'This is a good example';
new_claim = strrep(claim, 'good', 'great')
new_claim =
This is a great example.
% Example 2: Replace text in a cell array.
c_files = {'c:\cookies.m'; ...
'c:\candy.m'; ...
'c:\calories.m'};
d_files = strrep(c_files, 'c:', 'd:')
d_files =
'd:\cookies.m'
'd:\candy.m'
'd:\calories.m'
% Example 3: Replace text in a cell array with values in a second cell
% array.
missing_info = {'Start: __'; ...
'End: __'};
dates = {'01/01/2001'; ...
'12/12/2002'};
complete = strrep(missing_info, '__', dates)
complete =
'Start: 01/01/2001'
'End: 12/12/2002'
See also strfind, regexprep.
Reference page in Help browser
doc strrep
<strtok> - Find token in string.
STRTOK Find token in string.
TOKEN = STRTOK(STR) returns the first token in the string STR delimited
by white-space characters. STRTOK ignores any leading white space.
If STR is a cell array of strings, TOKEN is a cell array of tokens.
TOKEN = STRTOK(STR,DELIM) returns the first token delimited by one of
the characters in DELIM. STRTOK ignores any leading delimiters.
Do not use escape sequences as delimiters. For example, use char(9)
rather than '\t' for tab.
[TOKEN,REMAIN] = STRTOK(...) returns the remainder of the original
string.
If the body of the input string does not contain any delimiter
characters, STRTOK returns the entire string in TOKEN (excluding any
leading delimiter characters), and REMAIN contains an empty string.
Example:
s = ' This is a simple example.';
[token, remain] = strtok(s)
returns
token =
This
remain =
is a simple example.
See also isspace, strfind, strncmp, strcmp, textscan.
Overloaded methods:
cell/strtok
Reference page in Help browser
doc strtok
<strtrim> - Remove insignificant whitespace.
STRTRIM Remove insignificant whitespace.
S = STRTRIM(M) removes insignificant whitespace from string M.
Whitespace characters are the following: V = char([9 10 11 12 13 32]), which
return true from ISSPACE(V). Per definition, insignificant leading
whitespace leads the first non-whitespace character, and insignificant
trailing whitespace follows the last non-whitespace character in a string.
B = STRTRIM(A) removes insignificant whitespace from the char array.
D = STRTRIM(C), when C is a cell array of strings, removes insignificant
whitespace from each element of C.