1.0.4 • Published 2 years ago

hashtag-parser v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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"]