Skip to content

tropicalraisel/semver-regexp

Repository files navigation

Logo

semver-regexp

Semantic Version 2.0.0 library powered by Regex.


Live examples are on RunKit & Regex101!


NPM Badge Google Badge RunKit Badge RunKit Badge

Description

This package aims to fix issues with semver and semver-regex. Primarily, neither pass all tests provided on the semver website. Another small issue is that they allow invalid semantic version strings.

Usage

There are two functions, one default function that permits semantic version strings starting with ~, ^, or v, and another which strictly matches a semantic version.

ESM

import valid, { isValidSemanticVersion } from '@tropicalraisel/semver-regexp'

const version = 'v4.2.0'

console.log(valid(version))
console.log(isValidSemanticVersion(version))

CommonJS

const semver = require('@tropicalraisel/semver-regexp')

const version = 'v4.2.0'

console.log(semver.default(version))
console.log(semver.isValidSemanticVersion(version))