Created
October 19, 2015 06:39
-
-
Save lis186/35fc6adec171f6aa22d9 to your computer and use it in GitHub Desktop.
Search result highlight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var querystr = 'o'; | |
var result = 'Hello World'; | |
var reg = new RegExp(querystr, 'gi'); | |
var final_str = result.replace(reg, function(str) { | |
return '<strong>' + str + '</strong>'; | |
}); | |
// final_str = 'Hell<strong>o</strong> W<strong>o</strong>rld' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment