Skip to content

Commit 32a44c1

Browse files
committed
support matching "extended" punctuation characters
1 parent 14c7e3b commit 32a44c1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
'use strict';
99

10-
module.exports = function() {
11-
return /^[!"#$%&'()*+,./:;<=>?@\^_`{|}~-]+$/;
10+
module.exports = function(extended) {
11+
return extended === true
12+
? /^[\‒\–\—\―|$&~=\\\/@+*!?({[\]})<>«».;:^'",،`·\•°¡¿#÷×%\−§_¦]+$/
13+
: /^[!"#$%&'()*+,./:;<=>?@\^_`{|}~\-]+$/;
1214
};

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ describe('punctuation-regex', function() {
2222
assert(regex().test('/'));
2323
assert(regex().test('*'));
2424
});
25+
26+
it('should match extended punctuation characters', function () {
27+
assert(!regex().test('‘'));
28+
assert(regex(true).test('‘'));
29+
});
2530
});

0 commit comments

Comments
 (0)