Character Restrictions in a Text File

2 次查看(过去 30 天)
I am trying to restrict the 25th column of this text file by exporting entire line either of the following characters, "Ib, Ib/c, Ic, IIb, II, IIP, IIn, IIPec". How would I go about doing this?
I have attached my text file as a reference.

回答(1 个)

Walter Roberson
Walter Roberson 2015-10-19
contents = fileread('observedsn.txt');
[starts, stops] = regexp(contents, '^([^|]*\|){24}(Ib|Ib/c|Ic|II|IIP|IIn|IIPec)\|.*$', 'start', 'end', 'lineanchors', 'dotexceptnewline');
Now the relevant lines are at contents(starts(K):stops(K)) for K = 1 : length(starts)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by