var tys = $('.kmessage-thankyou'); for (var i = 0; i < tys.length; i++) { var src = $(tys[i]); var oldHTML = src.html(); var re = /and this user have (\d+) others thankyou/; oldHTML = oldHTML.replace(re, "+ $1 other(s)"); oldHTML = oldHTML.replace(/The following user\(s\) said Thank You:/,"Users that have thanked this post: "); src.html(oldHTML); }