matlab-字符数组与字符比较、字符分类

本文详细介绍了Python中字符串的拼接、比较、字符分类等核心操作,并通过实例展示了如何使用isletter、isspace、isstrprop等函数进行字符属性判断。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

>> x=['abc','defgh']

x =

abcdefgh

>> x={'abc','defgh'}

x =

    'abc'    'defgh'

>> y={'111','222'}

y =

    '111'    '222'

>> strcat(x,y)

ans =

    'abc111'    'defgh222'

 

 

 


>> x='aaa'

x =

aaa

>> y='a11'

y =

a11

>> x == y

ans =

     1     0     0

>>

 

 

>> strncmp('aaa','aa11',1)

ans =

     1

>> strncmp('aaa','aa11',2)

ans =

     1

 

 

>> strcmp('aaa','11')

ans =

     0

 

>> strncmp('aaa','aa11',3)

ans =

     0

 

 

字符分类:

是否为字母

>> isletter('sssaa11')

ans =

     1     1     1     1     1     0     0

是否为空格

>> isspace('s  ssaa11')

ans =

     0     1     1     0     0     0     0     0     0

是否为指定类型

>> isstrprop('s  ssaa11','alpha')

ans =

     1     0     0     1     1     1     1     0     0

>> isstrprop('s  ssaa11','alphanum')

ans =

     1     0     0     1     1     1     1     1     1

 

 Argument C must be a string from the following set:
    'alpha'     : classify S as in the alphabetic letter range
    'alphanum'  : classify S as in the alphanumeric range
    'cntrl'     : classify S as in the range of control characters, char(0:20).
    'digit'     : classify S as in the range of numeric digits
    'graphic'   : classify S as in the range of graphic characters. These are
                all values that represent characters NOT of the set
                {unassigned, space, line separator, paragraph separator, control
                characters, Unicode format control characters, private
                user-defined characters, Unicode surrogate characters, Unicode
                other characters}.
    'lower'     : classify S as in the range of lowercase letters
    'print'     : classify S as in the range of graphic characters, plus
                char(32).
    'punct'     : classify S as in the range of punctuation characters
    'wspace'    : classify S as in the range of whitespace characters; this
                range includes the ANSI C definition of whitespace,
                {' ','\t','\n','\r','\v','\f'}, in addition to a number of
                other Unicode characters.
    'upper'     : classify S as in the range of uppercase letters
    'xdigit'    : classify S as in the range of valid hexadecimal digits
 
    EXAMPLES
 
    B = isstrprop('abc123efg','alpha') returns B  => [1 1 1 0 0 0 1 1 1]
    B = isstrprop('abc123efg','digit') returns B  => [0 0 0 1 1 1 0 0 0]
    B = isstrprop('abc123efg','xdigit') returns B => [1 1 1 1 1 1 1 1 0]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值