Skip to content

Commit 5e98236

Browse files
committed
Add exact option
1 parent 849118e commit 5e98236

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ var visa = '(?:4[0-9]{12})(?:[0-9]{3})?';
1616
*/
1717

1818
function generate(pattern) {
19-
return function () {
20-
return new RegExp('(?:^|\\s)?(["\'])?' + pattern + '\\1', 'g');
19+
return function (opts) {
20+
opts = opts || {};
21+
return opts.exact ? new RegExp('(?:^' + pattern + '$)') :
22+
new RegExp('(?:^|\\s)?(["\'])?' + pattern + '\\1', 'g');
2123
};
2224
}
2325

0 commit comments

Comments
 (0)