I would like to know how to replace an irregular expression in javascript.I have tried what I have read on stackoverflow but its not working yet. I would like to replace all + with spaces.Here is my code
<script>
String.prototype.replaceAll = function(find,replace){
var str= this;
return.replace(new RegExp(find.replace(/[-\/\\^$*?.()|[\]{}]/g, '\\$&'),'g'), replace); };
$(document).ready(function(){
$('#myform').submit(function(){
var selectedItemsText = '';
$(this).find('input[type="checkbox"]:checked').each(function(){
selectedItemsText += $(this).val() + '\r';
});
selectedItemsText=selectedItemsText.replaceAll('+',' ');
if (confirm("Are you sure you would like to exclude these folders(s)?"+selectedItemsText))
{
$.ajax({
type:"POST",
url:catalog2.php,
data:$('#chk[]').val(),
});
}
return false;
});
});
</script>