[ruby-dev:51182] [Ruby master Bug#18802] Negation of POSIX character class does not work

From: cohei <noreply@...>
Date: 2022-05-25 02:41:12 UTC
List: ruby-dev #51182
Issue #18802 has been reported by cohei (昂平 谷口).

----------------------------------------
Bug #18802: Negation of POSIX character class does not work
https://bugs.ruby-lang.org/issues/18802

* Author: cohei (昂平 谷口)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.2
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
> https://docs.ruby-lang.org/ja/3.1/doc/spec=2fregexp.html#charclass_posix
> また、[:^クラス名:]という記法でその否定を意味します。

For example, `[:^ascii:]` is the negation of `[:ascii:]` according to the document. But it does not work:

```ruby
irb(main):001:0> RUBY_VERSION
=> "3.1.2"
irb(main):002:0> %w[あああ あ a b :].map { _1.match?(/[:^ascii:]/) }
=> [false, false, true, false, true] # matches a, c, i, s, : or ^
irb(main):003:0> %w[あああ あ a b :].map { _1.match?(/[^[:ascii:]]/) }
=> [true, true, false, false, false] # expected
```



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next