# hashtag-regex

> A regular expression to match hashtag identifiers as per the Unicode Standard.

Latest version **2.2.0** (published 2023-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install hashtag-regex
pnpm add hashtag-regex
yarn add hashtag-regex
bun add hashtag-regex
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2023-10-21 |
| First published | 2017-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/hashtag-regex) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | Mathias Bynens |
| Maintainers | mathias, google-wombot |
| Keywords | unicode, regex, regexp, regular expressions, code points, symbols, characters, emoji, hashtag, hashtags |

## Links

- npm: https://www.npmjs.com/package/hashtag-regex
- Repository: https://github.com/mathiasbynens/hashtag-regex
- Homepage: https://mths.be/hashtag-regex
- Issues: https://github.com/mathiasbynens/hashtag-regex/issues
- npm.io page: https://npm.io/package/hashtag-regex

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2023-10-21
- 2.1.0 — 2019-08-20
- 2.0.1 — 2019-08-20
- 2.0.0 — 2018-06-08
- 1.0.0 — 2017-03-30

## README

# hashtag-regex [![Build status](https://travis-ci.org/mathiasbynens/hashtag-regex.svg?branch=master)](https://travis-ci.org/mathiasbynens/hashtag-regex)

_hashtag-regex_ offers a regular expression to match hashtag identifiers [as per the Unicode Standard](http://unicode.org/reports/tr31/#hashtag_identifiers).

This repository contains a script that generates this regular expression based on the Unicode data. Because of this, the regular expression can easily be updated whenever the Unicode Standard changes.

## Installation

Via [npm](https://www.npmjs.com/):

```bash
npm install hashtag-regex
```

In [Node.js](https://nodejs.org/):

```js
const hashtagRegex = require('hashtag-regex');
// Note: because the regular expression has the global flag set, this module
// exports a function that returns the regex rather than exporting the regular
// expression itself, to make it impossible to (accidentally) mutate the
// original regular expression.

const text = `
#hashtag
#©
＃🤷🏿‍♀️ (\uFF03\u{1F937}\u{1F3FF}\u200D\u2640\uFE0F)
`;

const regex = hashtagRegex();
let match;
while (match = regex.exec(text)) {
  const hashtag = match[0];
  console.log(`Matched sequence ${ hashtag } — code points: ${ [...hashtag].length }`);
}
```

Console output:

```
Matched sequence #hashtag — code points: 8
Matched sequence #© — code points: 2
Matched sequence ＃🤷🏿‍♀️ — code points: 6
Matched sequence ＃🤷🏿‍♀️ — code points: 6
```

## Author

| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](https://mathiasbynens.be/) |

## License

_hashtag-regex_ is available under the [MIT](https://mths.be/mit) license.

---
_Source: https://npm.io/package/hashtag-regex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
