Aptivi - Manual
ProjectsWebsiteBlog
Textify - Manual
Textify - Manual
  • Welcome
  • Breaking changes
  • Usage
    • How to use
      • Basic Features
        • Text Manipulation
        • Other Tools
      • Extra Features
        • Space Analysis and Correction
        • Unicode Analysis
        • Semantic Versioning
        • Name Generation
        • Word Management
        • Accessibility Tools
        • Figlet Text
        • Emoji Management
        • Wide Characters
    • How it works
      • Space Analyzer Internals
      • Unicode Analyzer Internals
      • Semantic Versioning Internals
      • Name Generation Internals
      • Word Selection Internals
      • Figlet Text Internals
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
Edit on GitHub
  1. Usage
  2. How it works

Semantic Versioning Internals

How does it work?

Last updated 1 year ago

When SemVer.Parse() or SemVer.ParseWithRev() gets called with a semantic version string, it first checks the string against the SemVer compliance using the following regular expression (fetched from ). If it doesn't find any version element, such as the case of 1.0-1, it returns an error.

This is the regular expression used:

^(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 there's a match, the next step is to extract the following information:

  • Major version (MajorVersion, int)

  • Minor version (MinorVersion, int)

  • Patch version (PatchVersion, int)

  • Pre-Release info (PreReleaseInfo, string)

  • Build metadata (BuildMetadata, string)

Finally, the parser creates a new class instance which holds all the parsed information.

this