in reply to Regex Quantifiers

The first  .* in the regex  /.*(\d{6,8}).*/ immediately consumes all characters in the string. The regex then starts backtracking to try to find a match for 6 to 8 digits. It finds such a match in the 6 digits of  '345678'. The second  .* in the regex then tries to match zero or more of anything and, as one would expect, finds a match. The overall successful match then terminates.