I’m using jQuery to try something like this:
$('input').keyup(function(e){
var val = $(this).val();
var smileString = val.replace(/[:][)]/g, '<img src="smile.png" />');
$('#regexoutput').html(smileString);
var frownString = val.replace(/[:][(]/g, '<img src="frown.png" />');
$('#regexoutput').html(frownString);
})
Is there a way to do it with one expression? The above code only works for the bottom replace only.
1 Answer