<head>
<style>
#mydiv{ width:200pxheight:200pxborder:1px solid red}
</style>
<script language="javascript">
window.onload=function(){
var str="aaa111eee222rrr333"
var parter=/(\d+)/g
str=str.replace(parter,"<b>$1</b>")
document.getElementById("mydiv").innerHTML=str
}
</script>
</head>
<body>
<div id=mydiv></div>
</body>
</html>
试了一下,是可以的,不知你哪里写的不对.<script type="text/javascript">
tip = "thereare some words"
tip = tip.replace(/\s+/g, "\\ ")
alert(tip)
document.write(tip)
</script>