Get an array of hashtags extracted from a string
import extract from "hashtag-parser";
const hashtags = extract("Any text with #hashtag");
// hashtags = ["#hashtag"]
Parameters
- String
- Options (Object) | Optional
- symbol | Boolean
- unique | Boolean
- caseSensitive | Boolean
Returns
- Array
const hashtags = extract("Any text with #hashtag", { symbol: false });
// hashtags = ["hashtag"]
const hashtags = extract("Any text with #hashtag and another #hashtag", {
symbol: true, unique: true
});
// hashtags = ["#hashtag"]
const hashtags = extract("Any text with #hashtag and another #Hashtag", {
symbol: false, unique: true, caseSensitive: true
});
// hashtags = ["hashtag", "Hashtag"]