If the string is actually "Dog\nCat\nHamster"
then just do
"Dog\nCat\nHamster".split('\n');//returns ["Dog", "Cat", "Hamster"]
For a TextArea try this
myTextArea.value.split('\n'); // it will return desired output.
Where myTextArea
is the TextArea you can get using getElement
.