alterClass(removals, additions) {
    const self2 = this;
    if (removals.indexOf("*") === -1) {
      self2.removeClass(removals);
      return !additions ? self2 : self2.addClass(additions);
    }
    const patt = new RegExp(
      `\\s${removals.replace(/\*/g, "[A-Za-z0-9-_]+").split(" ").join("\\s|\\s")}\\s`,
      "g"
    );
    self2.each((i, it) => {
      let cn = ` ${it.className} `;
      while (patt.test(cn)) {
        cn = cn.replace(patt, " ");
      }
      it.className = $.trim(cn);
    });
    return !additions ? self2 : self2.addClass(additions);
  }
Remove element classes with wildcard matching. Optionally add classes:
  $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )