Use a limiting quantifier:
^[a-zA-Z]{1,15} [a-zA-Z]{1,20}$
^^^^^ ^^^^^^
The {1,15}
limiting quantifier tells the engine to match 1 to 15 characters matched with the subpattern that is located immediately to the left of it.
More from the docs:
The syntax is {min,max}, where min is zero or a positive integer number indicating the minimum number of matches, and max is an integer equal to or greater than min indicating the maximum number of matches. If the comma is present but max is omitted, the maximum number of matches is infinite. So {0,1}
is the same as ?
, {0,}
is the same as *
, and {1,}
is the same as +
. Omitting both the comma and max tells the engine to repeat the token exactly min times.