javascript - Regex to extract word from a line -


i trying extract word(s) inside round brackets.

code:

$('.vote').each(function() {  var vote_count = $('.vote .likedbutton').attr('title');  var split_count = vote_count.replace(/\(([^)]+)\)/,"");  alert(split_count); }); 

the string trying get-

message reputation : 50% (2 votes) trying 2 votes

the javascript regex have above deleting line. missing regex or need use

.match(/\(([^)]+)\)/); 

can explain thank you

live demo

$('.vote').each(function() {     var str = $('.likedbutton', this).attr('title');    $(this).prepend( str.match(/\(([^)]+)\)/)[1] );  }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -