3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unicodeの空白文字にマッチ

Posted at

Unicodeの空白文字がRuby 2.3.1の正規表現にどうマッチするかやってみた。

スクリプト

regexp =~ input_str ? '○' : '×'

結果

対象 \s [[:space:]] [[:blank:]] \p{Blank} [\s[:blank:]] \p{White_Space}
HORIZONTAL TABULATION (\u0009)
LINE FEED (\u000a) × ×
VERTICAL TABULATION (\u000b) × ×
FORM FEED (\u000c) × ×
CARRIAGE RETURN (\u000d) × ×
FILE SEPARATOR (\u001c) × × × × × ×
GROUP SEPARATOR (\u001d) × × × × × ×
RECORD SEPARATOR (\u001e) × × × × × ×
UNIT SEPARATOR (\u001f) × × × × × ×
SPACE (\u0020)
NO-BREAK SPACE (\u00a0) ×
OGHAM SPACE MARK (\u1680) ×
MONGOLIAN VOWEL SEPARATOR (\u180e) × × × × × ×
EN QUAD (\u2000) ×
EM QUAD (\u2001) ×
EN SPACE (\u2002) ×
EM SPACE (\u2003) ×
THREE-PER-EM SPACE (\u2004) ×
FOUR-PER-EM SPACE (\u2005) ×
SIX-PER-EM SPACE (\u2006) ×
FIGURE SPACE (\u2007) ×
PUNCTUATION SPACE (\u2008) ×
THIN SPACE (\u2009) ×
HAIR SPACE (\u200a) ×
ZERO WIDTH SPACE (\u200b) × × × × × ×
NARROW NO-BREAK SPACE (\u202f) ×
MEDIUM MATHEMATICAL SPACE (\u205f) ×
IDEOGRAPHIC SPACE (\u3000) ×
ZERO WIDTH NO-BREAK SPACE (\ufeff) × × × × × ×

参考

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?