function rtt(){ var textTagS, match; textTagS = $(".itsTag").text(); if( match = textTagS.match(/#(.+?)\s/) ) { alert('yes: ' + match[1]); }else{ alert('no'); } }