Skip to content

Instantly share code, notes, and snippets.

@accrane
Created June 9, 2020 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save accrane/34c228373537cc5a8bb9e3e0d60b1657 to your computer and use it in GitHub Desktop.
Save accrane/34c228373537cc5a8bb9e3e0d60b1657 to your computer and use it in GitHub Desktop.
strings
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