find specific text in a text file
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
amin
am 13 Feb. 2020
Kommentiert: amin
am 17 Feb. 2020
Hi
In the text file below, I want to obtain everything between "|[" and "]|".
system
component1 |[ b,a,d, w,e,r ]| component2
endsystem
so the output is : b,a,d, w,e,r
Thanks in advance.
0 Kommentare
Akzeptierte Antwort
Srivardhan Gadila
am 16 Feb. 2020
Let's assume that the following content
"system
component1 |[ b,a,d, w,e,r ]| component2
endsystem"
is in a text file named textFile.txt then the following code might help you:
textChar = fileread("textFile.txt");
startIndex = regexp(textChar,'|[');
endIndex = regexp(textChar,']|');
requiredOutput = textChar(startIndex+1:endIndex-2)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!