Asp > Strings
Highlight Word Function
Highlight Word Function <% ' YOU CAN CALL THE FUNCTION IN THE FOLLO ' WING WAYS mys = "This is a test To find the word you, it will highlight your, " w2f = "you" Response.Write doHighlight(mys, w2f, "bi") Response.Write "
" Response.Write doHighlight("This is a test To find the word you, it will highlight your...", "you", "bi") %> <% Function doHighlight(my_sentence, word_to_highlight, my_fn) ' doHighlight Function ' Description: Search for occurances of ' a keyword in a string and highlight them ' , by either bold, italic or boli-italic ' Inputs: String you want searched, word ' to highlight, and the type of highlight ' to perform. ' Types of highlight functions: b=bold; ' i=italic; bi=bold-italic ' Output: Returns the string with highli ' ghting. Select Case LCase(my_fn) Case "b" my_output = "
" & word_to_highlight & "
" doHighlight = Replace(my_sentence, word_to_highlight, my_output) Case "i" my_output = "
" & word_to_highlight & "
" doHighlight = Replace(my_sentence, word_to_highlight, my_output) Case "bi" my_output = "
" & word_to_highlight & "
" doHighlight = Replace(my_sentence, word_to_highlight, my_output) End Select End Function %>
Asp Codes
ActiveX
ADO
Array
Code Snippets
Components
Data Access
Date Time
Files
Graphics
HTML Formatting
Mathematics
Miscellaneous
Sessions
SQL
Strings
Techniques
XML