hashtag-parser

1.0.4 • Public • Published

Hashtag Parser

Get an array of hashtags extracted from a string

Usage

import extract from "hashtag-parser";

const hashtags = extract("Any text with #hashtag");

// hashtags = ["#hashtag"]

The extract() function

Parameters

  • String
  • Options (Object) | Optional
    • symbol | Boolean
    • unique | Boolean
    • caseSensitive | Boolean

Returns

  • Array

Options

Remove # symbol

const hashtags = extract("Any text with #hashtag", { symbol: false });

// hashtags = ["hashtag"]

Get unique values

const hashtags = extract("Any text with #hashtag and another #hashtag", {
  symbol: true, unique: true
});

// hashtags = ["#hashtag"]

Include case sensitive tags

const hashtags = extract("Any text with #hashtag and another #Hashtag", {
  symbol: false, unique: true, caseSensitive: true
});

// hashtags = ["hashtag", "Hashtag"]

Package Sidebar

Install

npm i hashtag-parser

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

3.27 kB

Total Files

4

Last publish

Collaborators

  • rajdeepghosh