Find part of string and remove entire line

3 vues (au cours des 30 derniers jours)
Jacky
Jacky le 11 Juin 2013
Hi,
I have a text file that looks like this 'textfile.txt':
'Algorithm: G:\folder: Example'
'2013-May-30 20:46:10'
'QAdR = 123678'
'QaDB = 9098'
'This is what I wanted'
How do i find all the special characters ':' & '=' and remove the entire row containing ':' & '=' and write it to 'textfile.txt'. My new 'textfile.txt' should only contain 'This is what I wanted'.

Réponses (1)

Angus
Angus le 11 Juin 2013
Modifié(e) : Angus le 11 Juin 2013
Hi, probably start by reading in the text file
filename='textfile.txt';
f=fopen(filename);
line1=fgetl(f);
Then you could check each line with a regexp and save it if it does not contain your characters.
if isempty(regexp(line1,'[:=]'))
...% save your line
end
and build a new text file from there.
Hope this helps as a start at least.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by