I got a problem with javascript RegExp. I want to replace the a.href
with textbox
value when I click on the button.But, I don't want to replace the whole string just want to find and replace those are exact match with my RegExp. Here is my code
$(document).ready(function(){
$('#btnRun').click(function(){
var str = encodeURIComponent($('#mydata').val());
var regExp = new RegExp('\\b' +encodeURIComponent( $('a').html()) + '\\b','gi');
$('a').attr('href',$('a').attr('href').replace(regExp,str));
});
});
this is my test code http://jsfiddle.net/4uAp5/1/