You could also create a GuiMLTextCtrl, set the text variable to the string with the \n's then just pull out getlines() which will return the lines as an array.
Another option is to savestring() to a temp file, then loadlines(). Both of these are kind of unnecessary though but should be mentioned regardless.
EDIT:
I don't get why you didn't just do like:
PHP Code:
function replacetext(text) {
return(text.tokenize("\n"));
}