Regex Stack Overflow

I am attempting to validate a “max” length text field against a Regular Expression of

^[,\s
]*\d{5,10}(?:[,\s
]+\d{5,10})*[,\s
]*$

In other words, I’m trying to validate that the field contains 1 or more 5-to-10-digit numbers separated by one or more delimiters (which can be spaces, commas, or new lines).

This all works fine for small lists. But once I start exceeding about 1000 items in the list, I start running into Stack Overflow Errors.

This is apparently a Known Issue with the java.util.regex library. See bugs 5050507 and 4675952

Has anyone else run into something like this?