Skip to content

Instantly share code, notes, and snippets.

@kianting
Created September 17, 2020 22:06
Show Gist options
  • Save kianting/02ff195e50b9c62de4a1b99bfd62c19a to your computer and use it in GitHub Desktop.
Save kianting/02ff195e50b9c62de4a1b99bfd62c19a to your computer and use it in GitHub Desktop.
Groovy Semvar Pattern Matching
​def semvarPattern = /^(?:(\d+)\.)?(?:(\d+)\.)+?(\*|\d+)$/
def version = '1.1.1.1.1.1.1'
if(!(version ==~ semvarPattern)){
println 'Semvar match fail !!!'
}​​else{
println 'Semvar match success !!!'
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment