Regular expression evaluation (`pattern.exec(data)`) must be repeated until there are no more matches in order to collect all matches for a multi-line body of text. The loop continues until there are no more matches (we have reached the end of the error text).