Generate format string from found pattern