I have the following problem, and that is that I have a chat to which I want to place a regular expression that substitutes a word for the nickname of the user who reads it. For example, I want to put a phrase that says
!! user are reading this
and I want the nickname of the person reading it instead of the user! Then I extracted the nickname of the user with which the corresponding command will be substituted. This is the code, it's with jQuery:
var usuario = $('#log_us').val();
the value that is obtained is the nick of the user, then I was experimenting:
function unescape2(m){
m=unescape(m);
m=m.replace(/</g,'<');
m=m.replace(/>/g,'>');
m=m.replace(/!code(.*)/ig, function(m, gg) {
if (gg == "" ) return m;
else return "<div style=\"font-family:monospace; color:#fff; display:inline-block; padding:4px; background-color:#000;\">" + gg + "</div>";
});
m=m.replace(/!anc(.*)/ig, function(m, gg) {
if (gg == "" ) return m;
else return "<div class=\"anunciacion oficial\">" + gg + "</div>"
});
m=m.replace(/#meneo(.*)/ig,function(m,gg){
if(gg=='') return m;
return "<div style='display:inline-block;' class='shke'>"+gg+"</div>"
});
m=m.replace(/#uppi(.*)/ig,function(m,gg){
if(gg=='') return m;
return "<div style='-webkit-transform:rotate(-180deg); -moz-transform:rotate(-180deg); -o-transform:rotate(-180deg); transform:rotate(-180deg); display:inline-block;'>"+gg+"</div>"
});
return m ;
}
that function is to enclose several commands, for example the #uppi makes the letters rotate 180 degrees, the #meneo move from side to side, and so, then I have no idea how to do what I want? Someone to guide me?