Skip to content

Instantly share code, notes, and snippets.

@georgekosmidis
Created March 20, 2023 08:58
Show Gist options
  • Select an option

  • Save georgekosmidis/c13a1ee04766918eddc7fd3aacd13c47 to your computer and use it in GitHub Desktop.

Select an option

Save georgekosmidis/c13a1ee04766918eddc7fd3aacd13c47 to your computer and use it in GitHub Desktop.
Suggested regular expression (RegEx) to check a SemVer string for BASH, as described in https://semver.org/
# Suggested regular expression (RegEx) to check a SemVer string for BASH
# as described in https://semver.org/
# Test here: https://regex101.com/r/qfrSak/1
^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment