javascript regex questions
I have a used a javascript replace to wrap all words seperated by a space, but it does only wrap numbers 开发者_如何学运维and letters, but i want it to wrap every character like dots, comma's, quotes etc
i have used this regex pattern
string.replace(/\b([\w+-]+)\b/g,'<b>$1</b>')
If you want to wrap anything that isn't a space, make your regex match everything that isn't a space. Try this one:
/([^\s]+)/g
Am I missing something here, or wouldn't
'<b>' + string + '</b>'
suffice?
精彩评论