This should be simple, once I figure out how, so I’m interested in the various ways to solve this while I search for an answer.
I have a what is essentially a db text field of html. I need to cut this in two parts based on finding a tag within the text.
In simple(but imagine this is a gigantic block of html):
lorem ipsum lorem ipsum lorem ipsum {CUT} lorem ipsum lorem ipsum lorem ipsum
I need to be able to deconstruct this into two parts, based on a {CUT} tag in the text. I’ve not done this yet, but imagine its been done.
What is the most efficient way to do this with Ruby? It is in a rails app, so if there is something rails(ish) to simplify this I’m unaware know of, that would be great. There is probably a thread here on stackoverflow, but I haven’t found one yet.
The block of HTML is so gigantic that a
string.split("{CUT}")won’t cut it?split("{CUT}", 2)will split it in, at most, two pieces, based on the first occurence of {CUT}.