In JavaScript you create a new RegExp object and then test it.
Something like this should work.
var string = $("#some_id").val();
var regexp = new RegExp("/#^\S+/");
if (regexp.test(string) === true) {
// do something here
return true; // optional
}
else {
// do something else here
return false; // optional
}