npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

doi-regex

v0.1.13

Published

Regular expression for matching DOIs

Downloads

4,718

Readme

doi-regex

Build Status FOSSA Status

Regular expression for matching DOIs

Parts of a DOI:

  • Directory Identifier: 10
  • Registrant code: . + [0-9]{2,}
  • Registrant subdivision (optional): . + [0-9]+
  • Suffix: / + any character, case insensitive for ASCII chars (but capitalised in the registry), with some characters that should be escaped
    Recommended encoding: "{}^[]`|\\&\/\'<>
    Mandatory encoding: %"#? and space.

From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2

Install

$ npm install --save doi-regex

Usage

var doiRegex = require('doi-regex');

// contains a DOI
doiRegex().test('unicorn 10.1000/xyz000');
//=> true

// is a DOI address
doiRegex({exact: true}).test('unicorn 10.1000/xyz000');
//=> false

doiRegex.declared({exact: true}).test('doi:10.1000/xyz000');
//=> true

doiRegex.groups().test('10.1000/xyz1000.a001');
//=> ['10.1000/xyz1000', '10.1000/xyz1000', '.a001']

'unicorn 10.1000/xyz000 cake 10.1000/xyz001 rainbow'.match(doiRegex());
//=> ['10.1000/xyz000', '10.1000/xyz000']

API

doiRegex(options)

Returns a regex for matching a DOI.

doiRegex.declared(options)

Returns a regex for matching a DOI that has been declared with a doi: string in front.

doiRegex.groups(doi)

Returns a regex match object with a final string as the first two indices, and any suffixes that are commonly used for supplemental information if they are attached to the doi. For instance, 10.1000/journal.pone.0000000.g001 would return 10.1000/journal.pone.0000000 and .g001.

options.exact

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

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

CLI

A CLI file has been provided. Run any of the examples provided above using your own DOI. For instance:

$ node cli-index.js -e 10.000/xyz1000
//=> true

Possible Flags:

  • -e, --exact Find an exact match
  • -d, --declared Find a DOI with a 'doi:' prefix
  • -m, --match Find all matches within the given string
  • -g, --groups Find the stripped DOI and any suffix it might have
  • -h, --help Display usage

Contribute

Please do!

License

MIT © Richard Littauer

FOSSA Status