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.
example:
open file test1.txt
look for : http
sample:
first
second
note: http…
third
fourth
output file: test2.txt
first
second
note:
third
fourth
lines can be small or large
thanks…
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:
http://bulletproofajax.com/code/chapter03/ajaxtest/ajaxtest.js
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);