Created
August 25, 2015 19:10
-
-
Save mbifulco/a242f67cb03caf7fca3d to your computer and use it in GitHub Desktop.
jquery dictionary
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
//characters we want to replace: | |
/* | |
< with < | |
> with > | |
*/ | |
var jsob = | |
{ | |
"<" : "<", | |
">" : ">" | |
}; | |
var replaceSpecialCharacters = function(input, dictionary) | |
{ | |
var res = input; | |
$.each(dictionary, function(key, value ){ | |
var find = key; | |
var replace = value; | |
find = new RegExp(find,"igm"); | |
res = res.replace(find,replace); | |
}); | |
return res; | |
}; | |
console.log(replaceSpecialCharacters("<em>hello</em>", jsob)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment