var angelweb="我,你,ta,";var re=/[,,]/g;if(re.test(angelweb)){ var n=angelweb.match(re).length; alert("字符串中包含"+n+"个逗号!"); }