Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

emoji_regex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emoji_regex

  • 15.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Ruby Emoji Regex 💎

Gem Version Node & Ruby CI

A Ruby regular expression for matching Unicode Emoji symbols.

Background

This is based upon the fantastic work from Mathias Bynens' emoji-test-regex-pattern package. emoji-test-regex-pattern is cleverly assembled based upon data from the Unicode Consortium.

The regular expressions provided herein are derived from that package.

Installation

gem install emoji_regex

Usage

emoji_regex provides the EmojiRegex::Regex regular expression, which matches emoji, as defined by the Unicode standard's emoji-test data file.

Example

require 'emoji_regex'

text = <<TEXT
\u{231A}: ⌚ default Emoji presentation character (Emoji_Presentation)
\u{2194}\u{FE0F}: ↔️ default text presentation character with Emoji variation selector
\u{1F469}: 👩 Emoji modifier base (Emoji_Modifier_Base)
\u{1F469}\u{1F3FF}: 👩🏿 Emoji modifier base followed by a modifier
TEXT

text.scan EmojiRegex::Regex do |emoji|
  puts "Matched sequence #{emoji} — code points: #{emoji.length}"
end

Console output:

Matched sequence ⌚ — code points: 1
Matched sequence ⌚ — code points: 1
Matched sequence ↔️ — code points: 2
Matched sequence ↔️ — code points: 2
Matched sequence 👩 — code points: 1
Matched sequence 👩 — code points: 1
Matched sequence 👩🏿 — code points: 2
Matched sequence 👩🏿 — code points: 2

Note: The above code and output are verified as part of the spec suite.

Development

Requirements

  • Ruby
  • Node (v6 or newer)
  • Yarn

Initial setup

To install all the Ruby and Javascript dependencies, you can run:

bin/setup

To update the Ruby source files based on the emoji-regex library:

bundle exec rake regenerate

Specs

A spec suite is provided, which can be run as:

bundle exec rake spec

Versioning Policy

Since Version 14.0.0, Ruby Emoji Regex's versions have followed that of the Unicode standard itself.

Ruby Emoji Regex is based upon the emoji-test-regex-pattern package.

  • If a patch revision of emoji-test-regex-pattern is released, and if its changes affect the Ruby port meaningfully, a version will be released with the same or greater patch version.
  • If a change is required to correct a bug specific to the Ruby port, the patch number will be incremented.

Ruby Compatibility Policy

While Ruby Emoji Regex uses features which should function on any Ruby version, it is explicitly intended to work on MRI Ruby versions which are currently within normal maintenance according to the Ruby team.

Creating a release

  1. Update the version in emoji_regex.gemspec
  2. rake release

FAQs

Package last updated on 05 Apr 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