This question is closed. Reopen it to edit or answer.
Any suggestions on how to write the best text-finding code (takes a given text and searches all files in provided folder for that string of text and outputs which files contain the text, as well as the location of the text within the file)?
1 view (last 30 days)
I have a folder full of text files, and I want the code to go through each file and search for a specified 5 character text (like abcde). If the 5 characters are there (in that order, like a word) then I want the code to tell me if the abcde is there and on which line. The code should then print out the 10 letters before this abcde and the 10 letters after the abcde. What is the best way to do this? It is for a protein sequence
Sid Jhaveri on 7 Dec 2016
You can refer to the links given below for information regrading the functions that that might be helpful in achieving you goal: https://www.mathworks.com/help/matlab/ref/contains.html
Basically, your code should:
1) Know which files are present in the directory and which files you would like to scan.
2) Read those files.
3) Check if the file contains the sequence.
Implementation of above steps can vary. But, I believe this information will be a good starting point for you.