Javascript examples for RegExp:Match Space
Check that Hashtag word must start with a space
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w . j a va 2 s . c o m*/ var text = document.getElementsByTagName('p')[0].innerHTML; document.body.innerHTML += /\s#([A-Za-z0-9_]+\b)/.exec(text)[0]; } </script> </head> <body> <p>some text #hashtag more text.</p> </body> </html>