Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
space = " "
japanese_space = [0x3000].pack('U')
puts "---"
puts "Space and \\s : #{!!space.match('\s')}"
puts "Japanese Space and \\s : #{!!japanese_space.match('\s')}"
puts "---"
puts "Space and [[:space:]] : #{!!space.match('[[:space:]]')}"
puts "Japanese Space and [::space:]] : #{!!japanese_space.match('[[:space:]]')}"
puts "---"
puts "Space and [[:punct:]] : #{!!space.match('[[:punct:]]')}"
puts "Japanese Space and [:punct:]] : #{!!japanese_space.match('[[:punct:]]')}"
# Output:
# ---
# Space and \s : true
# Japanese Space and \s : false
# ---
# Space and [[:space:]] : true
# Japanese Space and [::space:]] : false
# ---
# Space and [[:punct:]] : false
# Japanese Space and [:punct:]] : false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment