doHighlight

Search for occurrences of a keyword in a string and highlight them, by either bold, italic or boli-italic
With some work, we can add bootstrap highlighting, or some other html colors

CodeFunctionName
What is this?

Public

Tested

Imported
Function doHighlight(my_sentence, word_to_highlight, my_fn)
' doHighlight Function
' Author: Anthony Biondo (anthony.biondo@kmhp.com)
' 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 highlighting.
Select Case lcase(my_fn)
Case "b"
my_output = " <B >" & word_to_highlight & " </B >"
doHighlight = replace(my_sentence, word_to_highlight, my_output)
Case "i"
my_output = " <I >" & word_to_highlight & " </I >"
doHighlight = replace(my_sentence, word_to_highlight, my_output)
Case "bi"
my_output = " <I > <B >" & word_to_highlight & " </B > </I >"
doHighlight = replace(my_sentence, word_to_highlight, my_output)
End Select
End function

my_sentence, word_to_highlight, my_fn

response.write doHighlight("This is a test To find the word you, it will highlight your...", "you", "bi")

Views 4,297

Downloads 1,356

CodeID
DB ID