It depends on how specific and correct you want to be. A regex that perfectly matches the SemVer rules can be fairly long.
What I use for my projects is: /^v\d+\.\d+\.\d+$/
. It matches versions that start with a ‘v’ and is three integers separated by a decimal. It doesn’t go into betas and RCs or anything, but works for the simple stuff.