How about \d([:.]\d?)?? That should handle all the cases you mentioned.
Or \d+([:.]\d*?)? if you want to accept more than one digit in each number.
To only match if exact simply add ^ to the start and $ to the end of the regular expression. Example:
const regex = /^\d+([:.]\d*?)?$/ console.log(regex.test('2')) console.log(regex.test('2:')) console.log(regex.test('2.')) console.log(regex.test('2:3')) console.log(regex.test('2.3')) console.log(regex.test('12:23')) console.log(regex.test('23.34')) console.log(regex.test('2:3:4')) console.log(regex.test('2.3.4'))