1172| 65
|
【讨论】正则系列 |
| ||
| |
点评
考虑了大小写,贴上来时漏掉了,更改一下:sum(arrayfun(@(x0) numel(x0),regexpi(x,'[aeoiu]')))
与楼下相比,sum和arrayfun显得多余了,呵呵。
| ||
| ||
| ||
| ||
点评
正则系列的意思是,主题就不系列了,一个主题里,让题目系列吧,这样好管理也便于查找。最后再在1楼出个索引即可。
嗯,英雄所见略同,后面还会一点一点的出的
perfect,这个正则系列是不是标题可以写正则系列之【一】,可以出很多期
不错,应该也可以这样
numel(regexprep(lower(x),'[^aeiou]',''))
| ||
题目2——All Capticals?
| ||
| |
| |
| |
| ||
评分 | ||
点评
抱歉抱歉,弱智错误:居然直接F9,忘了这是带输入输出的函数,可运行.正写读书笔记,动态正则最后出一个section做专题,暂时不放在前面的解题思路中。
试了下,可以跑啊。这个就是solution 262252, cody上也通过了的。
www.mathworks.cn/matlabcentral/cody/problems/91-get-the-area-codes-from-a-list-of-phone-numbers/solutions/262252
代码无法通过,nwcwww兄检查一下?
个人深深觉得look around 是regexp的精华之一,变数很多,以后可以多做讨论
另外我这两个解只是利用了dynamic这种“作弊”手段而已,称不上真正的leading
评分 | ||
| |
题目四: Count letters
| ||
点评
dynamic不错,不过有空nwc兄可以展现另外两种用法
| ||
点评
dynamic无疑是减少代码size比较好的选择之一,不过本次讨论,本意是想给大家一个学习的平台,不以代码size为评价指标,在写代码时,最好能写下思路
| ||
点评
确实,按祁工说的在dynamics里加入多条语句即可。那么subref就不必要了,可以直接索引。
1.dynamic里面应该可以写多条语句
2.subref构造麻烦,不如用直接索引的方式
仅供参考
评分 | ||
| ||
Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )
GMT+8, 2024-9-22 09:22 , Processed in 0.075682 second(s), 23 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5 Licensed
© 2001-2024 Discuz! Team.