Skip to content

Instantly share code, notes, and snippets.

@everton
Created July 13, 2011 14:35
Show Gist options
  • Save everton/1080407 to your computer and use it in GitHub Desktop.
Save everton/1080407 to your computer and use it in GitHub Desktop.
jRuby bug with encoding
#-*- coding: utf-8 -*-
str = "<h1>Bugs#index</h1>
<%= @user %>
<p>á</p>"
str =~ /(?m-ix:<%(=+|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?)/
match = Regexp.last_match()
puts match.begin(0)
puts match.end(0)
# $ rvm use jruby-1.6.3
# Using /home/everton/.rvm/gems/jruby-1.6.3
# $ ruby test.rb
# 21
# 0
# $ rvm use ruby-1.9.2
# Using /home/everton/.rvm/gems/ruby-1.9.2-p180
# $ ruby test.rb
# 21
# 34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment