1
- ## [ ![ npm versi] [ npmjs-img ]] [ npmjs-url ] [ ![ mit license] [ license-img ]] [ license-url ] [ ![ build status] [ travis-img ]] [ travis-url ] [ ![ deps status ] [ daviddm -img]] [ daviddm -url] [ ![ regexps org ] [ regexps -img]] [ regexps -url]
1
+ ## [ ![ npm versi] [ npmjs-img ]] [ npmjs-url ] [ ![ mit license] [ license-img ]] [ license-url ] [ ![ build status] [ travis-img ]] [ travis-url ] [ ![ coveralls img ] [ coveralls -img]] [ coveralls -url] [ ![ deps status ] [ daviddm -img]] [ daviddm -url]
2
2
3
- > The correct mention(s) regex. Regular expression for twitter, facebook, github, etc user mentions
3
+ > 100% twitter compatible ` @mentions ` regex! Regular expression for matching ` @username ` mentions, as used on twitter, facebook, github, etc.
4
4
5
5
## Install
6
- ``` bash
7
- $ npm install mentions-regex
8
- $ npm test
6
+ ```
7
+ npm i --save mentions-regex
8
+ npm test
9
9
```
10
10
11
11
12
- ## [ . metntionsRegex] ( index.js#L16 )
13
- > Default regex is ` \s+@(\w{1,30})\s+ `
12
+ ## [ metntionsRegex] ( index.js#L17 )
13
+ > Compatible twitter mentions regex, not only of course!
14
14
15
- * ` [options] ` ** {Object}**
16
- - ` startSpace ` ** {Boolean}** if ` false ` , will remove starting ` \s+ ` from regex
17
- - ` endSpace ` ** {Boolean}** if ` false ` , will remove ending ` \s+ ` from regex
18
- - ` length ` ** {Number}** maximum length of mention, default ` 30 `
19
- - ` match ` ** {String}** what to match, default is ` \w{1,30} `
20
- - ` flags ` ** {String}** every valid RegExp flag, default ` undefined `
21
- - ` dot ` ** {Boolean}** will use ` [A-Za-z0-9_.] ` instead of ` \w `
15
+ * ` [dot] ` ** {Boolean}** if ` true ` it will allow to match dots
22
16
* ` return ` ** {RegExp}**
23
17
24
18
25
19
## Usage
26
20
> For more use-cases see [ tests] ( ./test.js )
27
21
28
22
``` js
29
- var mentionsRegex = require (' mentions-regex' );
30
-
31
- mentionsRegex ().test (' github @tunnckoCore' )
32
- // => false
33
-
34
- mentionsRegex ({flags: ' g' }).test (' github @tunnckoCore' )
35
- // => false
36
-
37
- mentionsRegex ({endSpace: false }).test (' github @tunnckoCore' )
38
- // => true
39
-
40
- var str
= ' @first git @tunnckoCore and @face some @al.so [email protected] glob @last'
41
-
42
- str .match (mentionsRegex ())
43
- // => [' @tunnckoCore ']
44
-
45
- str .match (mentionsRegex ({flags: ' g' }))
46
- // => [' @tunnckoCore ', ' @face ']
47
-
48
- str .match (mentionsRegex ({flags: ' g' , startSpace: false }))
49
- // => ['@first ', '@tunnckoCore ', '@face ']
50
-
51
- str .match (mentionsRegex ({flags: ' g' , endSpace: false }))
52
- // => [' @tunnckoCore ', ' @face ', ' @al', ' @last']
53
-
54
- str .match (mentionsRegex ({flags: ' g' , startSpace: false , endSpace: false }))
55
- // => ['@first', '@tunnckoCore', '@face', '@al', '@here', '@last']
56
-
57
- str .match (mentionsRegex ({length: 5 }))
58
- // => [' @face ']
59
-
60
- str .match (mentionsRegex ({flags: ' g' , dot: true }))
61
- // => [' @tunnckoCore ', ' @face ', ' @al.so ']
62
-
63
- str .match (mentionsRegex ({flags: ' g' , dot: true , length: 5 }))
64
- // => [' @face ', ' @al.so ']
65
-
66
- str .match (mentionsRegex ({flags: ' g' , dot: true , startSpace: false }))
67
- // => ['@first ', '@tunnckoCore ', '@face ', '@al.so ', '@here.com ']
68
-
69
- str .match (mentionsRegex ({flags: ' g' , dot: true , startSpace: false , endSpace: false }))
70
- // => ['@first', '@tunnckoCore', '@face', '@al.so', '@here.com ', '@last']
23
+ var metntionsRegex = require (' metntions-regex' );
71
24
```
72
25
73
26
@@ -81,7 +34,7 @@ str.match(mentionsRegex({flags: 'g', dot: true, startSpace: false, endSpace: fal
81
34
82
35
83
36
## License [ ![ MIT license] [ license-img ]] [ license-url ]
84
- Copyright (c) 2014 [ Charlike Mike Reagent] [ contrib-more ] , [ contributors] [ contrib-graf ] .
37
+ Copyright (c) 2014-2015 [ Charlike Mike Reagent] [ contrib-more ] , [ contributors] [ contrib-graf ] .
85
38
Released under the [ ` MIT ` ] [ license-url ] license.
86
39
87
40
@@ -113,7 +66,7 @@ Released under the [`MIT`][license-url] license.
113
66
114
67
***
115
68
116
- _ Powered and automated by [ readdirp + hogan.js ] ( https://github.com/tunnckoCore ) , December 21, 2014 _
69
+ _ Proudly generated with [ docks(1) ] ( https://github.com/tunnckoCore ) on March 28, 2015 _
117
70
118
71
119
72
0 commit comments