Low commit activity in last 3 years
A long-lived project that still receives updates
This small library lets you see which property values are supported by the regular expression engine of the Ruby version you are running, and what they match.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

RegexpPropertyValues

Gem Version Build Status

This small library lets you see which property values are supported by the regular expression engine of the Ruby version you are running and directly reads out their codepoint ranges from there.

That is, it determines all supported values for \p{value} expressions and what they match.

Usage

Browse all property values (supported by any Ruby, ever)
require 'regexp_property_values'

PV = RegexpPropertyValues

PV.all # => [<Value name='Alpha'>, <Value name='Blank'>, ...]
Browse property values supported by the Ruby you are running
PV.all_for_current_ruby # => [<Value name='Alpha'>, <Value name='Blank'>, ...]
Inspect property values
PV['alpha'].supported_by_current_ruby? # => true
PV['foobar'].supported_by_current_ruby? # => false

PV['AHex'].matched_characters # => %w[0 1 2 3 4 5 6 7 8 9 A B C ...]
PV['AHex'].matched_codepoints # => [48, 49, 50, ...]
PV['AHex'].matched_ranges # => [48..57, 65..70, 97..102]

PV['foobar'].matched_ranges # => RegexpPropertyValues::Error

If character_set is installed, you can also do this:

PV['AHex'].character_set # => #<CharacterSet: {48, 49...} (size: 22)>
Utility methods
# get a Hash of aliases for property names
PV.alias_hash # => { <Value name='M'> => <Value name='Mark'>, ... }

# download a list of possible properties for the running Ruby version
# (only used for .all and .alias_hash, not needed for prop lookup via .[])
PV.update