Regular Expressions using regexp

2 次查看(过去 30 天)
I have a cell array of strings a = {'-2.4,-3';'2,3';'0,5';'-4,-2.5';'A';'V';'C'}
Now I want to list those strings which have a "comma".

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-10-12
编辑:Azzi Abdelmalek 2013-10-12
a={'-2.4,-3';'2,3';'0,5';'-4,-2.5';'A';'V';'C'}
out=a(cellfun(@(x) ~isempty(strfind(x,',')),a))

更多回答(1 个)

Walter Roberson
Walter Roberson 2013-10-13
regexp(a, '.*,.*', 'match')

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by