JSPM

percentage-regex

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1529
  • Score
    100M100P100Q121020F
  • License MIT

Regex to match a percentage value

Package Exports

  • percentage-regex

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (percentage-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

percentage-regex Build Status

Regular expression to match percentage values

Install

$ npm install --save percentage-regex

Usage

var percentageRegex = require('percentage-regex');

'I am 99% sure that was a unicorn'.match(percentageRegex());
//=> ['99%']

'I had 83% for maths and 68% for French'.match(percentageRegex());
//=> ['83%', '68%']

percentageRegex({exact: true}).test('88%');
//=> true

API

percentageRegex(options)

Returns a regex for matching percentage values.

options.exact

Type: boolean
Default: false (Matches any percentage in a string)

Only match an exact string. Useful with RegExp#test to check if some string is a percentage.

License

MIT © Arthur Verschaeve