GithubHelp home page GithubHelp logo

wilmoore / uuid-regexp.js Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 12 KB

RegExp for finding an RFC4122 compliant UUID in a string.

License: MIT License

JavaScript 100.00%
uuid regexp regexps regex regexp-match regex-pattern regexes

uuid-regexp.js's Introduction

uuid-regexp

RegExp for finding an RFC4122 compliant UUID in a string.

Build Status Code Climate js-standard-style

npm install uuid-regexp --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads David

API Examples

API
var uuid = require('uuid-regexp')

uuid().exec('f47ac10b-58cc-4372-a567-0e02b2c3d479')
//=> [ 'f47ac10b-58cc-4372-a567-0e02b2c3d479', index: 0, input: 'f47ac10b-58cc-4372-a567-0e02b2c3d479' ]

uuid().test('f47ac10b-58cc-4372-a567-0e02b2c3d479')
//=> true

uuid().test('f47ac10b58cc4372a5670e02b2c3d479')
//=> true

uuid().test('F47AC10B58CC4372A5670E02B2C3D479')
//=> true

uuid({ nil: true }).test('00000000-0000-0000-0000-000000000000')
//=> true

uuid().test('00000000-0000-0000-0000-000000000000')
//=> false

'Secret UUID is: {4d36e96e-e325-11ce-bfc1-08002be10318}'.replace(uuid({ flags: 'g' }), '*****')
//=> 'Secret UUID is: {*****}'
RegExp
var regexp = require('uuid-regexp/regexp')

regexp.versioned.source
//=> '[a-f0-9]{8}-?[a-f0-9]{4}-?[1-5][a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}'

regexp.nil.source
//=> '[0]{8}-?[0]{4}-?[0]{4}-?[0]{4}-?[0]{12}'

API

uuid(options)

arguments
  • options.nil (Boolean) Whether to include the nil/empty UUID pattern. (default: false)
  • options.flags (String) Additional RegExp flags ('i' is always set).
returns
  • (RegExp) RegExp for matching an RFC4122 compliant UUID strings.

Inspiration

Contributing

SEE: contributing.md

Licenses

GitHub license

uuid-regexp.js's People

Contributors

wilmoore avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.