Q: Regular expression: cannot start with and exact number of digits I have to match a set of numbers that do not start with "3400" and must exactly be 13 digits.
So far this is what I've got: 
^(?:(?!3400).)*$

this makes it match with a set of characters that does not start with "3400"; but how do I impose the restriction of 13 digits?

A: The ^(?:(?!3400).)*$ pattern matches a string consisting of any chars other than line break chars, 0+ occurrences, that does not contain 3400 substring.
What you seek is to match a string consisting of 13 digits only and does not start with some custom digit sequences.
Use
^(?!3400])\d{13}$

to match 13 digit string that does not start with 3400.
You may further customize the pattern, e.g. to also avoid matching number strings starting with both 3400 and 3401 using
^(?!340[01])\d{13}$
       ^^^^

where [01]  is a character class matching either 0 or 1. ^(?!3400|3401)\d{13}$ is also possible, but it is best practice that alternatives should not match at the same location (and here, they both match 340), which impacts performance, especially with longer patterns and many more alternatives.
