Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/rexml/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/functions/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down