Created
September 11, 2014 16:35
-
-
Save hpjaj/33393c6a7160d1639c02 to your computer and use it in GitHub Desktop.
1e_split_a_string.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = "Welcome to the forum.\nHere you can learn Ruby.\nAlong with other members.\n" | |
def string_processor(non_split_string) | |
line_number = 0 | |
split_into_sentences = non_split_string.split(/\n/) | |
split_into_sentences.each do |sentence| | |
sentence.prepend("Line " + (line_number += 1).to_s + ": " ) | |
end | |
end | |
puts string_processor(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment