I think `doc = doc.replace(/^\/\*\*?/, '').replace(/\*\/$/, '');` seems preferable.