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
$('.vote').each(function() { var str = $('.likedbutton', this).attr('title'); $(this).prepend( str.match(/\(([^)]+)\)/)[1] ); });
Comments
Post a Comment