regexp to capture only certain length of characters
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I'm trying to capture words with 4 characters only. A word consists or alphanumeric characters.(no symbols of white space)
str4='4-44g 4541 75872 a4cd stuvw';
patt4='(\w{4,4})';
regexp(str4,patt4,'match')
I'm expecting 4541 a4cd as the correct answer. However my code outputs stuv & 7587 in addition. How can I correct this
0 件のコメント
回答 (2 件)
Rashmil Dahanayake
2014 年 8 月 7 日
1 件のコメント
Azzi Abdelmalek
2014 年 8 月 7 日
This doesn't work for underscore. For example
str4='4-44g 454_ 75872 abcd stuvw'
Azzi Abdelmalek
2014 年 8 月 7 日
str4='4-44g 4541 75872 a4cd stuvw';
regexpi([' ' str4 ' '],'(?<=[^0-9,a-z])[0-9,a-z]{4}(?=[^0-9,a-z])','match')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Encryption / Cryptography についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!