would like to know how or where i can find code to parse a ascii text file. it needs to open the file search for a specified keyword or phrase. if not found the write the line as is, if found the remove the target and wrte the rest of the line with out the target.
open file test1.txt
look for : http
output file: test2.txt
lines can be small or large
That can be done by reading the file in to a variable, and then using string-searching methods to look for what you want within that string.
An example of reading a file can be found in the Bulletproof Ajax book.
Their website makes all of the code freely available. In this cast it's from their Chapter 3 example, and the file that contains the Ajax code is in:
You would just need to remove the displayResponse function and instead return the result, so that you can assign it to a variable.
var content = grabFile(location);
This topic is now closed. New replies are no longer allowed.