Skip to content

Commit b97e0dc

Browse files
committed
Add options for exact or g regex
1 parent e289162 commit b97e0dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3-
module.exports = function() {
4-
return new RegExp('^\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*$');
3+
module.exports = function(options) {
4+
options = options || {};
5+
var regexBase = '\\s*(?:\\+?(\\d{1,3}))?[-. (]*(\\d{3})[-. )]*(\\d{3})[-. ]*(\\d{4})(?: *x(\\d+))?\\s*';
6+
7+
return options.exact ? new RegExp('^' + regexBase + '$') :
8+
new RegExp(regexBase, 'g');
59
}

0 commit comments

Comments
 (0)