mention-hashtag
Extract mentions (@mention) and/or hashtags (#hashtag) from any text
How to use
const extract = const mentions = ;// mentions == ['@mention'] const hashtags = ;// hashtags == ['#hashtag'] const all = ;// all == { mentions: ['@mention', '@othermention'], hashtags: ['#hashtag'] }
NOTE: The extract of mentions is by default. For extract hashtags, the '#' symbol in second parameter is required.
Options
Exclude repeated tokens
const mentions = ;// mentions == ['@mention', '@othermention'] const hashtags = ;// hashtags == ['#hashtag', '#otherhashtag'] const all = ;// all == { mentions: ['@mention'], hashtags: ['#hashtag'] }
NOTE: The symbol '#' is communicated in 'type' property of second parameter
Remove '@' and '#' symbols
const mentions = ;// mentions == ['mention', 'othermention'] const hashtags = ;// hashtags == ['hashtag', 'otherhashtag'] const all = ;// all == { mentions: ['mention'], hashtags: ['hashtag'] }
Mix
Unique, symbol and type properties are mixables
const mentions = ;// mentions == ['mention', 'othermention'] const hashtags = ;// hashtags == ['hashtag', 'otherhashtag'] const all = ;// all == { mentions: ['mention'], hashtags: ['hashtag'] }
Run test
$ npm install && npm test
License
MIT © lmfresneda