String replace with regular expression : Regular Expressions « Development « JavaScript DHTML
- JavaScript DHTML
- Development
- Regular Expressions
String replace with regular expression
<html>
<head>
<title></title>
<script type="text/javascript">
var pattern = /test/;
var string = "this is a test";
var result = string.replace(pattern, " unit test");
document.write(result);
</script>
</head>
<body>
</body>
</html>
Related examples in the same category