Jump to content

Site search


shaman

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...