我试图在所选框发生更改时提醒正则表达式值,选择框具有这样的值
#bla:123#bla2:12345
#bla:122#bla2:12111
#bla:663#bla2:93399
我正在使用 Jquery 获取选择框值,这是我一直在尝试的代码:
$(document).ready(function() {
$('#idNrel').change(function()
{
var re = /#.*:(.*)#.*:(.*)/;
var sourcestring = $('#idNrel').val();
var results = [];
var i = 0;
for (var matches = re.exec(sourcestring); matches != null; matches = re.exec(sourcestring)) {
results[i] = matches;
for (var j=0; j<matches.length; j++) {
alert("results["+i+"]["+j+"] = " + results[i][j]);
}
i++;
}
});
});