Git Product home page Git Product logo

sha-regex's Introduction

sha-regex Build Status XO code style

Regular expression for matching SHA hashes in strings.

Install

~ ❯❯❯ npm install sha-regex

Usage

const sha = require('sha-regex')

sha().test('nodejsrocks 84de6753b298abd027fcd1d790eade2413eafb5a')
//=> true

sha({exact: true}).test('nodejsrocks 84de6753b298abd027fcd1d790eade2413eafb5a foo')
//=> false

sha({exact: true}).test('84de6753b298abd027fcd1d790eade2413eafb5a')
//=> true

sha.version(256, {exact: true}).test('c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffcaf')
//=> true

sha.version(512, {exact: true}).test('84de6753b298abd027fcd1d790eade2413eafb5a')
//=> false

'nodejsrocks 	84de6753b298abd027fcd1d790eade2413eafb5a rainbow c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffcaf'.match(sha())
//=> ['84de6753b298abd027fcd1d790eade2413eafb5a','c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffca']

API

sha([options])

Returns a regex for matching SHA hashes.

options

Type: Object

exact

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

Only match an exact string. Useful with RegExp#test() to check if a string is a SHA hash.

sha.version(version, [options])

Returns a regex for matching specific SHA version hashes.

version

Type: integer
Supported Versions: 1, 224, 256, 384, 512

Match a specific version of SHA.

options

Type: Object

exact

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

Only match an exact string. Useful with RegExp#test() to check if a string is a SHA hash.

License

MIT © Nikolaos Kamarinakis

sha-regex's People

Contributors

dependabot[bot] avatar k4m4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.