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

unicoderegexp

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unicoderegexp

Regular expressions for various Unicode character classes extracted from XRegExp

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32K
decreased by-0.58%
Maintainers
2
Weekly downloads
 
Created
Source

unicoderegexp

Various regular expressions for unicode character classes (letter, punctuation, number, etc.) and helper functions for composing them.

Used by the purify library.

The module exports a bunch of useful RegExps each with a single character class in them:

  • letter
  • mark
  • number
  • punctuation
  • symbol
  • separator
  • other
  • visible
  • printable
unicodeRegExp.visible.test("a"); // true
unicodeRegExp.visible.test(" "); // false
unicodeRegExp.visible.test("\u00a0"); // false -- a non-breaking space is not visible

To validate an entire string you need to build a new RegExp:

var visibleStringRegExp = new RegExp('^' + unicodeRegExp.visible.source + '*$');
visibleStringRegExp.test("foobar"); // true
visibleStringRegExp.test("foo bar"); // false because of the space

unicodeRegExp.removeCharacterFromCharacterClassRegExp(/[æøå]/, 'æ'); // /[\u00f8\u00e5]/
unicodeRegExp.spliceCharacterClassRegExps(/[a-b]/, /[c-d]/); // /[a-bc-d]/

The info about which characters belong to which classes was taken from the XRegExp library and its Unicode plugin.

Keywords

FAQs

Package last updated on 20 Aug 2015

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