You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # semver-regex [![Build Status](https://travis-ci.org/sindresorhus/semver-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/semver-regex)
  2. > Regular expression for matching [semver](https://github.com/npm/node-semver) versions
  3. ## Install
  4. ```
  5. $ npm install semver-regex
  6. ```
  7. ## Usage
  8. ```js
  9. const semverRegex = require('semver-regex');
  10. semverRegex().test('v1.0.0');
  11. //=> true
  12. semverRegex().test('1.2.3-alpha.10.beta.0+build.unicorn.rainbow');
  13. //=> true
  14. semverRegex().exec('unicorn 1.0.0 rainbow')[0];
  15. //=> '1.0.0'
  16. 'unicorn 1.0.0 and rainbow 2.1.3'.match(semverRegex());
  17. //=> ['1.0.0', '2.1.3']
  18. ```
  19. ## Related
  20. - [find-versions](https://github.com/sindresorhus/find-versions) - Find semver versions in a string
  21. - [latest-semver](https://github.com/sindresorhus/latest-semver) - Get the latest stable semver version from an array of versions
  22. - [to-semver](https://github.com/sindresorhus/to-semver) - Get an array of valid, sorted, and cleaned semver versions from an array of strings
  23. - [semver-diff](https://github.com/sindresorhus/semver-diff) - Get the diff type of two semver versions: `0.0.1` `0.0.2` → `patch`
  24. - [semver-truncate](https://github.com/sindresorhus/semver-truncate) - Truncate a semver version: `1.2.3` → `1.2.0`
  25. ## License
  26. MIT © [Sindre Sorhus](https://sindresorhus.com)