I have two text fields, 1) Page Title and 2) URI. As and when the user types in the Page Title, I want the text to be copied straight into the URI text field, but after having made all letters small and replacing ' ' (space) with '-' minus sign.

This is what I have so far:
<script type = "text/javascript">
function transfer(which) {
	reg = /\s+/;

	document.getElementById("uri").value = which.toLowerCase().replace(reg,'-');
<input type="text" name="title" id="title" value="" size="32" onkeyup = "transfer(this.value)">
<input type="text" name="uri" id="uri" value="" size="32">
case lowering works fine, but with space replacement, it only replaced the first space with '-', and leaves the rest of the spaces as they are.

Hence, this is how it looks:

Page Title: This is my Pompous Page Title
URI: this-is my pompous page title

How can I get it to continue replacing all spaces and not just the first one?