unicoderegexp
Regular expressions for various Unicode character classes extracted from XRegExp
Last updated 11 years ago by papandreou .
Repository · Original npm · Tarball · package.json
$ gnpm install unicoderegexp 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.4.1                                ...           latest (9 years ago)

10 Versions

  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.4                                ...           11 years ago
  • 0.2.3                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.2                                ...           11 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 12
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |