PDA

View Full Version : search for a specific string of text and then return the line number?



jhancock
22nd July 2010, 17:05
I'm looking for the best way in QT to search for a specific string of text and then return the line number.
For example I have a txt file that has the following in it:

1 Detroit Tigers
2 Chicago White Sox
3 Minnesota Twins

I want to search for the word Twins and return the string 3.

Any ideas??

Thanks

Lykurg
22nd July 2010, 17:12
read the file line by line in and check every line for your pattern. This is probably the fastest way.