regex - jQuery - regexp selecting and removeClass()? -


i've been given several auto-generated html docs thousands of lines long, , need clean source. need remove classnames "table-col-##". two-step problem:

  1. select , classes have table-col-##, ## integer between 0-999
  2. remove matching class element, without removing of other classes

so boils down to: need way, if possible, use regexps in $() selectors, , either obtain selected class in each() - or apply regexp $.removeclass(). can point me in right direction?

update: there sort of $.removeclass([selected]) functionality? seems easiest way solve second part.

if numbers acceptable, there can other characters too, start (not tested, edited comments):

$("[class^='table-col-']").removeclass( function() { /* matches table-col-row */      var toreturn = '',          classes = this.classname.split(' ');      for(var = 0; < classes.length; i++ ) {          if( /table-col-\d{1,3}/.test( classes[i] ) ) { /* filters */              toreturn += classes[i] +' ';          }      }      return toreturn ; /* returns classes removed */ }); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -