Javascript examples for RegExp:RegExp test
Javascript regex and trim everything after dash
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.4.js"></script> <script type="text/javascript"> $(window).load(function(){// w ww . ja v a2s .c om var matches = $('.review-rating').text().match(/\s*By\s+(\w+)\s*-\s*([\w, ]+)/); console.log(matches); }); </script> </head> <body> <p class="review-rating"> By oakbarrels - Dec 25, 2011 - Something.com </p> </body> </html>