How to find and remove certain text from a text file
Show older comments
Hi,
I am having trouble removing specific text from a text file. I have a long text file that contains 5 columns and many rows
I am looking for something similar to the functionality of ctrl+F and then remove all of the strings. Essentially I want to isolate the file so it just displays only positive and negative numbers next to Sum-Pnt
3 Comments
Bob Thompson
on 8 Aug 2019
Assuming all rows of the file are the same, I would suggest using regexp.
number = regexp(text,'Sum-Pnt(.\d.\d+)\s+.*','tokens');
The example will only work for one line at a time, so you might want to loop and index it.
Rik
on 13 Aug 2019
Did you delete comments on this thread? That is considered very rude. You're getting free help with your problem, the least you can do is leaving the thread for other people with a similar problem.
And if your flag ("Similar answers available elsewhere on mathworks") is true, why did you need to post the question? Apparently the other threads weren't enough to help you. Maybe this thread will help someone in the future.
@Bob, can you confirm there are deleted comments? In that case, feel free to flag this question so they can be restored.
Pineapple
on 14 Aug 2019
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!