How would I go about removing the characters < and > from only a specific part of a string, say from the first 200 characters in that string? Those characters should remain untouched if they appeared after the 200 character mark.
3 Answers
Assuming what you want to do is replace the < and > characters with placeholders, you can do it like this:
if original_string.length >= 200
original_string = original_string[0..199].gsub(/</,"<").gsub(/>/,">") + original_string[200..-1]
else
original_string = original_string.gsub(/</,"<").gsub(/>/,">")
end
You could also use "" as the substitution string.