@@ -10,9 +10,62 @@ $ npm install mentions-regex
10
10
$ npm test
11
11
```
12
12
13
+
13
14
## Usage
14
15
> For more use-cases see [ tests] ( ./test.js )
15
16
17
+ ``` js
18
+ var mentionsRegex = require (' mentions-regex' );
19
+
20
+ mentionsRegex ().test (' github @tunnckoCore' )
21
+ // => false
22
+
23
+ mentionsRegex ({flags: ' g' }).test (' github @tunnckoCore' )
24
+ // => false
25
+
26
+ mentionsRegex ({endSpace: false }).test (' github @tunnckoCore' )
27
+ // => true
28
+
29
+ var str
= ' @first github @tunnckoCore and @face some @al.so [email protected] global @last'
30
+
31
+ str .match (mentionsRegex ())
32
+ // => [' @tunnckoCore ']
33
+
34
+ str .match (mentionsRegex ({flags: ' g' }))
35
+ // => [' @tunnckoCore ', ' @face ']
36
+
37
+ str .match (mentionsRegex ({flags: ' g' , startSpace: false }))
38
+ // => [' @tunnckoCore ', ' @face ', '@face ']
39
+
40
+ str .match (mentionsRegex ({flags: ' g' , endSpace: false }))
41
+ // => [' @tunnckoCore ', ' @face ', ' @al', ' @last']
42
+
43
+ str .match (mentionsRegex ({flags: ' g' , startSpace: false , endSpace: false }))
44
+ // => ['@first', '@tunnckoCore', '@face', '@al', '@here', '@last']
45
+
46
+ str .match (mentionsRegex ({length: 5 }))
47
+ // => [' @face ']
48
+
49
+ str .match (mentionsRegex ({flags: ' g' , dot: true }))
50
+ // => [' @tunnckoCore ', ' @face ', ' @al.so ']
51
+
52
+ str .match (mentionsRegex ({flags: ' g' , dot: true , length: 5 }))
53
+ // => [' @face ', ' @al.so ']
54
+ ```
55
+
56
+
57
+ ## [ .metntionsRegex] ( index.js#L16 )
58
+ > Default regex is ` \s+@(\w{1,30}|[A-Za-z0-9_.]{1,30})\s+ `
59
+
60
+ * ` [options] ` ** {Object}**
61
+ - ` startSpace ` ** {Boolean}** if ` false ` , will remove starting ` \s+ ` from regex
62
+ - ` endSpace ` ** {Boolean}** if ` false ` , will remove ending ` \s+ ` from regex
63
+ - ` length ` ** {Number}** maximum length of mention, default ` 30 `
64
+ - ` match ` ** {String}** what to match, default is ` \w{1,30} `
65
+ - ` flags ` ** {String}** every valid RegExp flag, default ` undefined `
66
+ - ` dot ` ** {Boolean}** replace options.match which is ` \w ` with ` [A-Za-z0-9_.] `
67
+ * ` return ` ** {RegExp}**
68
+
16
69
17
70
## Authors & Contributors
18
71
** Charlike Mike Reagent** [ ![ author tips] [ author-gittip-img ]] [ author-gittip ]
0 commit comments