I have a string that may contains the next characters '&' and/or '<' and/or '>'
for each one of these characters I need to replace it with Charater ref in html :
- '&' -> "& ;"
- '<' -> '< ;'
- '>' -> '> ;'
I have implimented this using the following code and it's working:
if( _.contains(note,"&")){
note = note.replace("&","&");
}if( _.contains(note,"<")){
note = note.replace("<","<");
}if( _.contains(note,">")){
note = note.replace(">",">");
}
return note;
is there a shorter way to impliment this ?