troubleshooting Question

search function using a keyword on a text file in C#

Avatar of quicknowledge
quicknowledge asked on
8 Comments1 Solution1869 ViewsLast Modified:
Just want to know if its possible to do a search function using a keyword on a text file in C#.

For example,
lets just call the text file test.txt, and the content of the file is

BOOK xxx,yyy,zzz
   AUTHOR xy, yx, yy
   YEAR 1999,1929,2009
   PRICE 99,77,195
   COMMENT very very good
MAGAZINE asd,avacs,etc
   COVER hard, soft

So BOOK is the keyword and AUTHOR, YEAR, PRICE and COMMENT are sub-keywords marked by spaces before the words(likewise for MAGAZINE and COVER).
What I'm after is when user type in keyword BOOK, it returns the whole 5 lines starting from BOOK to COMMENT. And when user types in PRICE, it returns only 1 line(PRICE 99,77,195).

The output could be just a display in the console.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros