Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6248405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:03:06+00:00 2026-05-24T13:03:06+00:00

According to the Oniguruma documentation , the \d character type matches: decimal digit char

  • 0

According to the Oniguruma documentation, the \d character type matches:

decimal digit char
Unicode: General_Category — Decimal_Number

However, scanning for \d in a string with all the Decimal_Number characters results in only latin 0-9 digits being matched:

#encoding: utf-8
require 'open-uri'
html = open("http://www.fileformat.info/info/unicode/category/Nd/list.htm").read
digits = html.scan(/U\+([\da-f]{4})/i).flatten.map{ |s| s.to_i(16) }.pack('U*')

puts digits.encoding, digits
#=> UTF-8
#=> 0123456789٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹߀߁߂߃߄߅߆߇߈߉०१२३४५६७८९০১২৩৪৫৬৭৮৯੦੧੨…

p RUBY_DESCRIPTION, digits.scan(/\d/)
#=> "ruby 1.9.2p180 (2011-02-18) [i386-mingw32]"
#=> ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

Am I misreading the documentation? Why doesn’t \d match other Unicode numerals, and/or is there a way to make it do so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:03:07+00:00Added an answer on May 24, 2026 at 1:03 pm

    Noted by Brian Candler on ruby-talk:

    • \w only matches ASCII letters and digits, while [[:alpha:]] matches the full set of Unicode letters.
    • \d only matches ASCII digits, while [[:digit:]] matches the full set of Unicode numbers.

    The behavior is thus ‘consistent’, and we have a simple workaround for Unicode numbers. Reading up on \w in the same Oniguruma doc we see the text:

    \w  word character  
        Not Unicode: alphanumeric, "_" and multibyte char.  
        Unicode: General_Category -- (Letter|Mark|Number|Connector_Punctuation)
    

    In light of the real behavior of Ruby and the “Not Unicode” text above, it would appear that the documentation is describing two modes—a Unicode mode and a Not Unicode mode—and that Ruby is operating in the Not Unicode mode.

    This would explain why \d does not match the full Unicode set: although the Oniguruma documentation fails to describe exactly what is matched when in Not Unicode mode, we now know that the behavior documented as “Unicode” is not to be expected.

    p "abç".scan(/\w/), "abç".scan(/[[:alpha:]]/)
    #=> ["a", "b"]
    #=> ["a", "b", "\u00E7"]
    

    It is left as an exercise to the reader to discover how (if at all) to enable Unicode mode in Ruby regexps, as the /u flag (e.g. /\w/u) does not do it. (Perhaps Ruby must be recompiled with a special flag for Oniguruma.)

    Update: It would appear that the Oniguruma document I have linked to is not accurate for Ruby 1.9. See this ticket discussion, including these posts:

    [Yui NARUSE] “RE.txt is for original Oniguruma, not for Ruby 1.9’s regexp. We may need our own document.”
    [Matz] “Our Oniguruma is forked one. The original Oniguruma found in geocities.jp has not been changed.”

    Better Reference: Here is official documentation on Ruby 1.9’s regexp syntax:
    https://github.com/ruby/ruby/blob/trunk/doc/re.rdoc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to
According to the feedparser documentation , I can turn an RSS feed into a
According to the documentation , socket_read() is supposed to return FALSE when the remote
According to be Spring Framework documentation, logging is the only mandatory dependency of Spring.
According to MDN documentation for JSON.stringify : Properties of non-array objects are not guaranteed
According to the PHP Documentation PDO::prepare() adds quotes to all your parameters so that
According to 8.2 The Null Type chapter of Ecma-262 null is type. But typeof(null)
According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to the MSDN documentation , a ribbon:RibbonControlSizeDefinition can be used to control the
According documentation: System.Array.Sort<T> - sorts the elements in an entire System.Array using the System.IComparable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.