Extract regexp segment to var