shaman Posted June 14, 2008 Share Posted June 14, 2008 In google, under the link which displays the title of a page that contains the search term you were looking for, there's a description.The description shows a part of the text from the page on which the search terms you entered were found.If I were making a site search, how would I show the text? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 18, 2008 Share Posted June 18, 2008 That's a pretty vague question, and there's not one answer. I would probably scan through the text looking for each search term and if I found one I would get a substring of 30 or 40 characters with the term right in the middle, for context. But like I said, there's not one answer, you just think about how you want it to work and then how to make that happen. Link to comment Share on other sites More sharing options...
shaman Posted June 19, 2008 Author Share Posted June 19, 2008 Say you wanted to show 4-6 words before and after the word "jump" is found in a textfile called "test.txt" what code would you do? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 23, 2008 Share Posted June 23, 2008 Well, personally I would use Javascript. The FileSystemObject is used to open and read the file. Once you have the file data, you can either use the string object for string.indexOf to get the position of a specific thing (it would be case-sensitive), or you could use a regular expression to search for the term. I'm sure there's a way to get information in a regular expression pattern before and after the match but I haven't done that. It would be quicker then using the string object though. For the string object though if you know the index of the term using indexOf then you can use string.substr to get a substring that contains the term. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.