in reply to Breaking up a string?
Maybe if you showed the purported "ugly and inefficient" code someone could help you clean it up . . .
See also How (Not) To Ask A Question.
The cake is a lie. The cake is a lie. The cake is a lie.