I do not think there is a succinct way to do the comparison of version numbers using regular expressions but the regular expressions can be used to check the format of the version numbers and get the parts in one shot:

    version.match(/^(\d+)(?:\.(\d+)(?:\.(\d+))?)?$/)

Will return null if the format is incorrect. If correct, will return an array of match information.