New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hashtag-regex

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashtag-regex

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

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.9K
increased by17.56%
Maintainers
2
Weekly downloads
 
Created
Source

hashtag-regex Build status

hashtag-regex offers a regular expression to match hashtag identifiers as per the Unicode Standard.

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:

npm install hashtag-regex

In Node.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
Mathias Bynens

License

hashtag-regex is available under the MIT license.

Keywords

FAQs

Package last updated on 21 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc