I want to limit the matches to 7 digits at most, but at the same time I want to allow zeroes in front of the number. Right now it's allowing numbers such as 0, 1, 12, 123, 1234, 12345, 123456, 1234567 which is expected. This is the problem, I also want to find a match for numbers such as 0001234567 but not 12345678. This is the regex I'm using:
/^[1-9][0-9]{0,6}$|^0$/g