Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaynetics/regexp_property_values
Inspect property values supported by Ruby's regex engine
https://github.com/jaynetics/regexp_property_values
onigmo oniguruma regular-expression ruby unicode
Last synced: 3 months ago
JSON representation
Inspect property values supported by Ruby's regex engine
- Host: GitHub
- URL: https://github.com/jaynetics/regexp_property_values
- Owner: jaynetics
- License: mit
- Created: 2018-05-11T16:23:50.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T10:38:51.000Z (9 months ago)
- Last Synced: 2024-05-22T10:48:09.633Z (9 months ago)
- Topics: onigmo, oniguruma, regular-expression, ruby, unicode
- Language: Ruby
- Homepage:
- Size: 61.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RegexpPropertyValues
[![Gem Version](https://badge.fury.io/rb/regexp_property_values.svg)](http://badge.fury.io/rb/regexp_property_values)
[![Build Status](https://github.com/jaynetics/regexp_property_values/workflows/tests/badge.svg)](https://github.com/jaynetics/regexp_property_values/actions)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)
```ruby
require 'regexp_property_values'PV = RegexpPropertyValues
PV.all # => [, , ...]
```##### Browse property values supported by the Ruby you are running
```ruby
PV.all_for_current_ruby # => [, , ...]
```##### Inspect property values
```ruby
PV['alpha'].supported_by_current_ruby? # => true
PV['foobar'].supported_by_current_ruby? # => falsePV['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]
# Note: #matched_characters is slow for large properties and you
# may not want to use it in time-critical code. It also omits surrogates.PV['foobar'].matched_ranges # => RegexpPropertyValues::Error
```If [`character_set`](https://github.com/jaynetics/character_set) is installed, you can also do this:
```ruby
PV['AHex'].character_set # => #
```##### Utility methods
```ruby
# get a Hash of aliases for property names
PV.alias_hash # => { => , ... }# 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
```