var text = "1234:1234-2222@你好啊,1234:1234-2222@我很好,1234:1234-2222@去你的,1234:1234-2222@ 哈哈"; text = text.replace(/(^|,).*?@\s*/g, ","); text = text.replace(/^,+|,+$/, ""); alert(text);
alert(str.match(/@[^,]*/g))
<script> window.onload=function(){ var str = "1234:1234-2222@你好啊,1234:1234-2222@我很好,1234:1234-2222@去你的,1234:1234-2222@哈哈"; alert(str.match(/[^@]+?(,|$)/g).join("")); } </script>
text = text.replace(/(^|,).*?@\s*/g, ",");
text = text.replace(/^,+|,+$/, "");
alert(text);
alert(str.match(/@[^,]*/g))
window.onload=function(){
var str = "1234:1234-2222@你好啊,1234:1234-2222@我很好,1234:1234-2222@去你的,1234:1234-2222@哈哈";
alert(str.match(/[^@]+?(,|$)/g).join(""));
}
</script>
join("")//容易理解