<script type="text/javascript">
// Store the current title value
var title = 'This is a title with a symbol &'
// alert(title); // debug
// Clean up the title
var url = title
.toLowerCase() // change everything to lowercase
.replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces
.replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
.replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
.replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
.replace(/^-+|-+$/g, "") // trim leading and trailing hyphens
;
alert(url); // outputs 'this-is-a-title-with-a-symbol'
</script>
但是中文就没了。。。
