Trim matched regex.