We tried to split text in a JTextArea using a regular expression to split the String by \n . But, this is not working. We also tried by using \r\n|\r|n and many other combinations of regexes. Code:
public void insertUpdate(DocumentEvent e) {
    String split[], docStr = null;
    Document textAreaDoc = (Document)e.getDocument();
    try {
        docStr = textAreaDoc.getText(textAreaDoc.getStartPosition().getOffset(), textAreaDoc.getEndPosition().getOffset());
    } catch (BadLocationException e1) {
        e1.printStackTrace();
    }
    split = docStr.split("\\n");
}