Note that using parentheses in the regex allows you to refer to the matched bit using $1, so you can provide the replacement as a string in the second argument to .replace() rather than passing a function.

Email codedump link for jQuery: Selected text and making bold apart from first word