Created
June 9, 2020 19:27
-
-
Save accrane/34c228373537cc5a8bb9e3e0d60b1657 to your computer and use it in GitHub Desktop.
strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myTitles = Array.prototype.slice.apply(document.querySelectorAll("h2.woocommerce-loop-product__title")); | |
const searchTerm = '('; | |
// console.log( myTitles ); | |
const regExp = /\(([^)]+)\)/; | |
myTitles.forEach((myTitles) => { | |
//console.log("apply worked"); | |
if( myTitles.innerHTML.indexOf(searchTerm) > -1 ) { | |
// console.log('yep'); | |
let matches = regExp.exec(myTitles.innerHTML); | |
console.log('<br>('+matches[1]+')'); | |
matches = matches.repalce(matches, '<br>('+matches[1]+')'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment