find/remove 2 consecutive letters from string
4 ビュー (過去 30 日間)
古いコメントを表示
Tried the regexp(regexprep) family, still don't know how to get this to work...
I have a cell array of strings, some of which looks like: '.XNY.N'
I simply need to check the cell array, if there is a .N or .M, remove it. Same as in excel you select an array and replace .N and .M with empty.
So in this case '.XNY.N' will be '.XNY'
Anyone knows how to do that? Thanks in advance!
0 件のコメント
採用された回答
Andrei Bobrov
2012 年 1 月 3 日
regexprep('.XNY.N','[.]N','')
2 件のコメント
Walter Roberson
2012 年 1 月 3 日
Andrei's answer involved [.] with a period between the brackets. That is one of the ways in which you can code a literal period. Normally in regular expressions, a period is interpreted to mean "any character". You can also use \. to indicate a literal period.
その他の回答 (1 件)
Walter Roberson
2012 年 1 月 3 日
Slightly closer to your original question, and using a different regexp pattern:
regexprep('.XNY.N','\.[MN]','')
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!