<html>
<head>
<title></title>
<script language="javascript">
function replaceAll()
{
var str = document.all('book').value;
var newValue = str.replace(new RegExp("\"","gm"),"“");
document.all('book').value = newValue;
}
</script>
</head>
<body>
<form>
<input type="button" value="替换" onclick="replaceAll();"/>
<textarea cols="50" rows="10" id="book" name="book">
</textarea>
</form>
</body>
</html>
方法二:
<script>
String.prototype.replaceAll = function (AFindText,ARepText){
raRegExp = new RegExp(AFindText,"g");
return this.replace(raRegExp,ARepText);
}
alert("axxxbxxxxcxxxxx".replaceAll("x", "_"))
</script>