You can't use word boundaries (`\b`) for this since hyphens are valid in class names. You need something like `new RegExp('(?:^|\\s)' + tclass + '(?:\\s|$)')`.