<html> <head> <script type="text/javascript"> var pattern = /is (.*) test/; var string = "this is a test"; var result = string.replace(pattern, "not unit $1 test"); document.write(result); </script> </head> <body> </body> </html>