🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

semver-regex

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
s

semver-regex

Regular expression for matching semver versions

4.0.5
latest
100

Supply Chain Security

100

Vulnerability

71

Quality

76

Maintenance

100

License

Version published
Weekly downloads
5M
-18.46%
Maintainers
1
Weekly downloads
 
Created
Issues
1

What is semver-regex?

The semver-regex npm package provides a regular expression for matching semantic versioning (semver) strings. Semantic versioning is a versioning scheme for software that conveys meaning about the underlying changes. The semver-regex package allows users to easily validate and extract semver strings from text.

What are semver-regex's main functionalities?

Validation of semver strings

This feature allows you to test if a string is a valid semantic version. The code sample demonstrates how to use the semver-regex package to validate a correct semver string ('1.0.0') and an incorrect one ('1.0').

const semverRegex = require('semver-regex');
console.log(semverRegex().test('1.0.0')); // true
console.log(semverRegex().test('1.0')); // false

Extraction of semver strings

This feature allows you to extract a semver string from a larger piece of text. The code sample shows how to use the semver-regex package to find and extract the first semver string from a given text.

const semverRegex = require('semver-regex');
const text = 'The latest version is 3.2.1.';
console.log(text.match(semverRegex())[0]); // '3.2.1'

Other packages similar to semver-regex

FAQs

Package last updated on 08 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts