How can I split an HTML element?

How to split HTML textarea element into array of lines in Java

  • How to split HTML textarea element into array of lines in Java

  • Answer:

    If you mean Java and not Javascript (assuming you have a JSP system): String[] lines = myTextArea.getText().split("\\n"); or String[] lines = request.getParameter("textarea").split("\\n"); Edited down: For javascript: var lines = document.getElementById("myTextArea").value.split('\\n');

Svet at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

In Java, get the text and pass it to a method like: private String[] split(String s) { if (s==null) { return new String[0]; } StringTokenizer st = new StringTokenizer(s,"\n"); ArrayList list = new ArrayList(); while (st.hasMoreElements()) { list.add(st.nextToken()); } return (String[]) list.toArray(new String[list.size()]); }

Bruno Rothgiesser

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.