Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isspace

Determine which character array elements are space characters

Syntax

TF = isspace(A)

Description

example

TF = isspace(A) returns a logical array TF. If A is a character array, the elements of TF are logical 1 (true) where corresponding elements of A are space characters, and logical 0 (false) elsewhere. isspace recognizes all Unicode® whitespace characters.

If A is not a character array, then isspace returns logical 0 (false).

Examples

collapse all

Create different arrays, and then determine which elements are space characters.

chr = '123 Main St.'
chr = 
'123 Main St.'
TF = isspace(chr)
TF = 1×12 logical array
   0   0   0   1   0   0   0   0   1   0   0   0

Starting in R2016b, you can convert character arrays to strings using the string function. Convert chr to a string, and test it. The input argument is not a character array, so isspace returns 0.

str = string(chr)
str = 
"123 Main St."
TF = isspace(str)
TF = logical
   0

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. A can be any data type.

Tips

  • To find space characters within elements of a string array, use the isstrprop function.

  • To find all characters for which isspace returns logical 1, use the code below. Then look up the returned decimal codes in a Unicode reference, such as the List of Unicode characters.

    find(isspace(char(1):char(intmax('uint16'))))

Extended Capabilities

Introduced before R2006a

Was this topic helpful?