`(\'?)([^\']*)\3` might be a better way of phrasing this, assuming it works.