加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

MATLAB中的findstr()和strfind()函数 查找字符串

(2013-08-05 10:33:18)
标签:

字符串

函数

教育

matlab

分类: matlab基础
matlab中这两个字符串查找的函数findstr(), strfind()表明上看起来用法相似,效果也相似。
1. findstr(s1,s2)--在较长的字符串中查找较短的字符串出现的次数,并返回其位置,因此无论s1,s2哪个为长字符串,位置在前在后都没有关系。
 
例:
s = 'Find the starting indices of the shorter string.';
findstr(s, 'the')
ans =
     6    30
findstr('the', s)
ans =
     6    30
 
2. strfind(s1,s2)--or strfind(s1,pattern),因此其意思在s1中搜索pattern,
例:
S = 'Find the starting indices of the pattern string';
strfind(S, 'in')
ans =
     2    15    19    45
strfind(S, 'In')
ans =
     []

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有