diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb index 106a21ee..f84b846b 100644 --- a/lib/rexml/functions.rb +++ b/lib/rexml/functions.rb @@ -205,8 +205,13 @@ def substring_before( string, test ) # Kouhei fixed this too def substring_after( string, test ) ruby_string = string(string) - return $1 if ruby_string =~ /#{test}(.*)/ - "" + ruby_test = string(test) + ruby_index = ruby_string.index(ruby_test) + if ruby_index.nil? + "" + else + ruby_string[(ruby_index + ruby_test.length)..-1] + end end # Take equal portions of Mike Stok and Sean Russell; mix diff --git a/test/functions/test_base.rb b/test/functions/test_base.rb index 44f07c11..b63f3d5a 100644 --- a/test/functions/test_base.rb +++ b/test/functions/test_base.rb @@ -126,6 +126,8 @@ def test_substring def test_substring_angrez testString = REXML::Functions::substring_after("helloworld","hello") assert_equal( 'world', testString ) + testString = REXML::Functions::substring_after("helloworld","hel.o") + assert_equal( '', testString ) end def test_translate