findstr()与strfind()的区别
来源:互联网 发布:sql查询字段长度限制 编辑:程序博客网 时间:2024/06/03 23:48
转载“http://blog.sina.com.cn/s/blog_49c07d4801000a3x.html”
matlab中这两个字符串查找的函数findstr(), strfind()表明上看起来用法相似,效果也相似。
1. findstr(s1,s2)--在较长的字符串中查找较短的字符串出现的次数,并返回其位置,因此无论s1,s2哪个为长字符串,位置在前在后都没有关系。
例:
s = 'Find the starting indices of the shorter string.';
findstr(s, 'the')
ans =
findstr('the', s)
ans =
2. strfind(s1,s2)--or strfind(s1,pattern),因此其意思在s1中搜索pattern,
例:
S = 'Find the starting indices of the pattern string';
strfind(S, 'in')
ans =
strfind(S, 'In')
ans =
看例子似乎挺简单的,但具体用到我的例子上则有问题,前面的findstr(s1,s2)掉换位置,提示出错。刚刚检查发现是元胞结构体的问题,使用textread()读进来的字符串为什么成cell结构?
通过cell2mat()可以把cell结构转成数据,findstr(),strfind()函数只能对一维字符串数据进行操作,若是二维字符串则得使用别的函数。
0 0
- findstr()与strfind()的区别
- findstr()与strfind()的区别
- Matlab中findstr()与strfind()的区别
- matlab中findstr 与 strfind的两个函数举例
- matlab中的findstr与strfind函数
- MATLAB中的findstr()和strfind()函…
- findstr的使用
- Findstr
- findstr
- findstr
- Findstr
- findstr的命令行分析机制
- Windows下的grep命令--findstr
- window下的grep:findstr 使用
- windows下的grep命令——findstr
- 批处理命令findstr正则表达式的基本用法
- Findstr 命令
- find findstr
- 微信企业号之新增用户
- linux命令大全
- uva 10341 - Solve It(二分)
- JavaScript几个比较事件触发方式的记录
- 多线程通信之优化升级+JDK1.5升级版后的新方案
- findstr()与strfind()的区别
- CSS学习笔记二(W3CSchool)
- 黑马程序员--异常处理知识点总结
- 局部变量和全局变量在内存中的存储位置
- 从人人网“死亡”看“级联”效应
- hdu 1007最近点对
- Linux服务器安装jdk和tomcat
- hdu 1285(拓扑排序)
- 第十一周 项目一 存储班长信息的学生类(1)