javascript-replace
javascript-replace-all javascript-replaceall
v_value='1<z><z>2<z><z><z><z>3<z><z>'
s0=_lookup("moduleACLChoice").replace(/,/g,"|");
s1=_lookup("roleChoice").replace(/,/g,"|");
v_value=v_value.replace(/<z><z>/g, '\n'); <z><z>=source \n = targetv_value=v_value.replace(/source/g, '\target'); <z><z>=source \n = target
<html>
<body>
<script type="text/javascript">
var str="Visit Microsoft!"
document.write(str.replace(/Microsoft/,"Google"))
s3=_lookup('address2').replace(/,/g,"|");
s4=_lookup('address3').replace(/,/g,"|"); // replace all
</script>
</body>
</html>
replace with variable
var reg = new RegExp(oldWord,"g");
myString.replace(reg, "");
or simply:
myString.replace(new RegExp(oldWord,"g"), "");
沒有留言:
張貼留言