Hi, i must convert a string (user generated) to a regex rule.
My problem is that i must say,
replace every sign but not a-b, 0-9, minus, dot and comma
I hope somebody can help.
HTML
<div id="d1" class="line1"></div>
JS
$(function() {
new_regex_rule = 'hello,bl.com,dkd-dkd.com,blub,blib,satssan kommt';
// new_regex_rule = new_regex_rule.replace(/[a-z][0-9][-.]/gi,'');
$('#d1').append('<hr />'+new_regex_rule+'<hr />');
if(new_regex_rule.match(/\s/)){ new_regex_rule = new_regex_rule.replace(/\s/,'\\s'); }
if(new_regex_rule.match(/,/)){ new_regex_rule = new_regex_rule.replace(/\,/,'|'); }
$('#d1').append('<hr />'+new_regex_rule+'<hr />');
});
working example
http://www.jsfiddle.net/V9Euk/517/
Thanks in advance! Peter
EDIT: Or is ist maybe possible to use the string as regex rule as it is?