I am trying to match hash tags and wrap them with an anchor tag. Here is the POC:
You can solve it this way (it's much simpler, actually):
var content = "I like #redApple. I have a #black hat. #red is my favorite color";
var re = /(#[a-z0-9][a-z0-9\-_]*)/ig;
content = content.replace(re, function(x) { return '' + x + ' '; });
$(".display").append(content);
vSearch = value.replace(/[-\/\\^$*+?.=()|[\]{}]/g, '\\$&'); in your code is redundant - you don't need it since your matches won't have any of these symbols according to regexp you used to get them.