Skip to content

Instantly share code, notes, and snippets.

@allensarkisyan
Last active August 28, 2020 12:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save allensarkisyan/5441601 to your computer and use it in GitHub Desktop.
Save allensarkisyan/5441601 to your computer and use it in GitHub Desktop.
SMPTE Time Code RegExp Pattern for matching SMPTE time codes that have a frame rate of 23.98, 24, 25, 29.97, or 30.
/**
* @author Allen Sarkisyan
* @copyright 2013
* @license Open Source MIT License
*/
/**
* Assumes the frame rate is 23.98, 24, 25, 29.97 NDF, or 30
*
* This pattern basically matches the hours being less then 24, the minutes, and seconds
* being less than 60, the frame count being less than 30, and the existence of 3 colons.
* might also rewrite this in the future to support semi colons
*/
var isValidSMPTETimeCode = new RegExp(/(^(?:(?:[0-1][0-9]|[0-2][0-3]):)(?:[0-5][0-9]:){2}(?:[0-2][0-9])$)/);
// var isValidSMPTETimeCode = /(^(?:(?:[0-1][0-9]|[0-2][0-3]):)(?:[0-5][0-9]:){2}(?:[0-2][0-9])$)/;
// isValidSMPTETimeCode.test('00:12:11:23')
@rmolinamir
Copy link

rmolinamir commented Jun 24, 2020

With semi-colons: ^([0-1][0-9]|[0-2][0-3]):([0-5][0-9]):([0-5][0-9])[:;]([0-6][0-9])$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment