Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2010 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/592990 to your computer and use it in GitHub Desktop.
Save anonymous/592990 to your computer and use it in GitHub Desktop.
# $KCODE will change the way your regexps match characters:
puts "\xc6\xb5".gsub(/./,"x") # -> xx
puts "\xc6\xb5".gsub(/./u,"x") # -> x
puts "\xc6\xb5".gsub(/./n,"x") # -> xx
$KCODE='u'
puts "\xc6\xb5".gsub(/./,"x") # -> x (different default!)
puts "\xc6\xb5".gsub(/./u,"x") # -> x
puts "\xc6\xb5".gsub(/./n,"x") # -> xx (/n means no encoding, aka byte-wise matching)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment