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]
22
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.
44
55## Install
6- ``` bash
7- $ npm install mentions-regex
8- $ npm test
6+ ```
7+ npm i --save mentions-regex
8+ npm test
99```
1010
1111
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!
1414
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
2216* ` return ` ** {RegExp}**
2317
2418
2519## Usage
2620> For more use-cases see [ tests] ( ./test.js )
2721
2822``` 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@here.com 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' );
7124```
7225
7326
@@ -81,7 +34,7 @@ str.match(mentionsRegex({flags: 'g', dot: true, startSpace: false, endSpace: fal
8134
8235
8336## 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 ] .
8538Released under the [ ` MIT ` ] [ license-url ] license.
8639
8740
@@ -113,7 +66,7 @@ Released under the [`MIT`][license-url] license.
11366
11467***
11568
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 _
11770
11871
11972
0 commit comments