0
1

More than 3 years have passed since last update.

セマンティックバージョニングを正規表現で評価する

Posted at

公式リンク↓↓

セマンティックバージョニング2.0.0(最後の方に載ってます)

見るのが面倒な人向け↓↓

const regex = new RegExp(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/);
if(regex.test(hogehoge)){
  console.log("OK")
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1