File tree Expand file tree Collapse file tree 4 files changed +35
-9
lines changed Expand file tree Collapse file tree 4 files changed +35
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ /**
4
+ * Parts of a DOI:
5
+ * Directory Identifier: 10
6
+ * Registrant code: . + [0-9]{4,}
7
+ * Registrant subdivision (optional): . + [0-9]+
8
+ * Suffix: / + any character, case insensitive for ASCII chars (but capitalised
9
+ * in the registry), with some characters that _should_ be escaped.
10
+ * Recommended encoding: "{}^[]`|\\&\/\'<>
11
+ * Mandatory encoding: %"#? (and space)
12
+ * From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2
13
+ */
14
+
3
15
// TODO Capture final segment for fragments
4
16
// (\\.[a-zA-Z]{1}[0-9]{3})?
5
- var doiRegex = '(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\/\'<> ])\\S)+)'
17
+ var doiRegex = '(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?![%"#? ])\\S)+)'
6
18
var doiTextPrefix = 'doi\\:'
7
19
8
20
var doi = module . exports = function ( opts ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " doi-regex" ,
3
- "version" : " 0.0.5 " ,
3
+ "version" : " 0.0.6 " ,
4
4
"description" : " Regular expression for matching DOIs" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 2
2
3
3
> Regular expression for matching DOIs
4
4
5
+ Parts of a DOI:
6
+ * Directory Identifier: 10
7
+ * Registrant code: . + [ 0-9] {4,}
8
+ * Registrant subdivision (optional): . + [ 0-9] +
9
+ * Suffix: / + any character, case insensitive for ASCII chars (but capitalised
10
+ in the registry), with some characters that _should_ be escaped
11
+ Recommended encoding: ```"{}^[]`|\\&\/\'<>```
12
+ Mandatory encoding: ``` %"#? ``` (and space)
13
+
14
+ From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2
15
+
5
16
6
17
## Install
7
18
@@ -62,18 +73,17 @@ Useful with `RegExp#test` to check if a string is an DOI.
62
73
A CLI file has been provided. Run any of the examples provided above using your own DOI. For instance:
63
74
64
75
``` sh
65
- $ node cli-index.js -e ` 10.000/xyz1000`
66
- true
76
+ $ node cli-index.js -e 10.000/xyz1000
77
+ //= > true
67
78
```
68
79
69
- Run it without arguments to see all possible flags.
70
-
71
80
Possible Flags:
72
81
73
82
* ` -e ` , ` --exact ` Find an exact match
74
83
* ` -d ` , ` --declared ` Find a DOI with a 'doi:' prefix
75
84
* ` -m ` , ` --match ` Find all matches within the given string
76
85
* ` -g ` , ` --groups ` Find the stripped DOI and any suffix it might have
86
+ * ` -h ` , ` --help ` Display usage
77
87
78
88
## License
79
89
Original file line number Diff line number Diff line change @@ -4,13 +4,17 @@ var _ = require('lodash')
4
4
var doiRegex = require ( './' ) ;
5
5
6
6
var doi = [
7
- '10.1371/journal.pone.0077056'
7
+ '10.0001/journal.pone.000001' ,
8
+ '10.0001/journal/pone.0011111' ,
9
+ '10.0001.112/journal.pone.0011021' ,
10
+ '10.0001/issn.10001'
8
11
] ;
9
12
10
13
var doiNot = [
11
- '10.1000//journal.pone.0011111' ,
12
14
'10..1000/journal.pone.0011111' ,
13
- '1.1/1.1'
15
+ '1.1/1.1' ,
16
+ '10/134980' ,
17
+ '10.001/001#00'
14
18
] ;
15
19
16
20
var doiDeclared = [
You can’t perform that action at this time.
0 commit comments