doi-regex

Regular expression for matching DOIs

https://github.com/regexhq/doi-regex

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 14 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.9%) to scientific vocabulary

Keywords

doi doi-regex regex regular-expression
Last synced: 6 months ago · JSON representation ·

Repository

Regular expression for matching DOIs

Basic Info
  • Host: GitHub
  • Owner: regexhq
  • License: mit
  • Language: HTML
  • Default Branch: main
  • Homepage:
  • Size: 349 KB
Statistics
  • Stars: 31
  • Watchers: 9
  • Forks: 5
  • Open Issues: 0
  • Releases: 5
Topics
doi doi-regex regex regular-expression
Created about 11 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

readme.md

doi-regex

FOSSA Status DOI

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/doihandbook/2Numbering.html#2.2

Install

sh $ npm install --save doi-regex

Usage

```js 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/xyz001'] ```

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:

sh $ 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

Owner

  • Name: RegexHQ
  • Login: regexhq
  • Kind: organization
  • Location: Global

Collaboration on a world-wide community-driven collection of RegExp patterns and tools that can make our life easier.

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: doi-regex
message: Regular expression for matching DOIs
type: software
authors:
  - given-names: Richard
    family-names: Littauer
    orcid: 'https://orcid.org/0000-0001-5428-7535'
  - given-names: Katrin
    family-names: Leinweber
    orcid: 'https://orcid.org/0000-0001-5135-5758'
  - family-names: 'b1f6c1c4'
    orcid: 'https://orcid.org/0000-0003-4080-1876'
  - given-names: Chris
    family-names: Wilkinson
    orcid: 'https://orcid.org/0000-0003-4921-6155'
  - given-names: Karl
    family-names: Becker
    orcid: 'https://orcid.org/0009-0002-2714-7988'
identifiers:
  - type: doi
    value: 10.5281/zenodo.11164918
    description: Zenodo DOI
repository-code: 'https://github.com/regexhq/doi-regex'
abstract: Regular expression for matching DOIs.
keywords:
  - doi
  - regex
license: MIT
commit: 320096e7fd6d1663719b009fcd7572496181f9fa
version: 0.1.17
date-released: '2024-06-14'

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 5
  • Total pull requests: 9
  • Average time to close issues: 3 days
  • Average time to close pull requests: 2 months
  • Total issue authors: 1
  • Total pull request authors: 7
  • Average comments per issue: 0.0
  • Average comments per pull request: 1.89
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • RichardLitt (5)
Pull Request Authors
  • RichardLitt (4)
  • katrinleinweber (2)
  • greenkeeper[bot] (1)
  • karlbecker (1)
  • b1f6c1c4 (1)
  • fossabot (1)
  • thewilkybarkid (1)
Top Labels
Issue Labels
Pull Request Labels
greenkeeper (1)

Packages

  • Total packages: 1
  • Total downloads:
    • npm 2,865 last-month
  • Total dependent packages: 7
  • Total dependent repositories: 39
  • Total versions: 24
  • Total maintainers: 1
npmjs.org: doi-regex

Regular expression for matching DOIs

  • Versions: 24
  • Dependent Packages: 7
  • Dependent Repositories: 39
  • Downloads: 2,865 Last month
Rankings
Dependent repos count: 2.1%
Downloads: 2.5%
Dependent packages count: 2.8%
Average: 4.4%
Stargazers count: 7.0%
Forks count: 7.7%
Maintainers (1)
Last synced: 7 months ago

Dependencies

package-lock.json npm
  • 268 dependencies
package.json npm
  • faucet 0.0.1 development
  • istanbul ^0.4.5 development
  • lodash ^4.16.5 development
  • minimist ^1.1.0 development
  • standard ^16.0.4 development
  • tape ^4.6.2 development