0.0.1 • Published 7 years ago
mention-parser v0.0.1
mention-parser
Parse and replace mentions from string
Install
$ yarn add mention-parser
Usage
const mentionParser = require('mention-parser')
const str = 'hey @bukinoshita and @here, check this #channel!'
mentionParser(str).get()
// => ['@bukinoshita', '@here']
mentionParser(str, { prefix: '#' }).get()
// => ['#channel']
mentionParser(str).replace(mention => `<a href="/channel">${mention}</a>`)
// => 'hey <a href="/bukinoshita">@bukinoshita</a> and <a href="/here">@here</a>, check this #channel!'
API
mentionParser(input, options)
input
Type: string
Required
string to be parsed
options
Type: object
prefix
Type: string
Default: @
Options: @
or #
methods
.get()
Returns an array
with mentions
.replace(fn)
fn
Type: function
License
MIT © Bu Kinoshita
0.0.1
7 years ago