grep to match two occurrences of the same pattern with a certain number of characters in between

On a Mac I would try with {0,5} instead of an empty entry ({,5}). Because the empty entry is a GNU extension which may not be supported on the Mac.

Also, just like with the other regex characters, the { and } should be escaped \{0,5\} should work best.

If the 0 is an issue (invalid count), then you can make it with an extra set of parenthesis:

\(.\{1,5\}\)\?

That means those 1 to 5 characters are optional.