title: Java space and newline regex for split
body: <p>for this below method i can find <code>http://</code> and <code>www</code> into text and i can create html link from that, but in this method i can only split text with <code>\n</code> and i want to split with <code>\n</code> with space, how to use regex for this action?</p>
  
  <pre><code>public static Spanned Htmlparser(String text) {
          String[] tokens = text.split("\n");
          StringBuilder sbStr = new StringBuilder();
          for (int i = 0; i &lt; tokens.length; i++) {
              if ((tokens[i]).contains("www.")) {
                  String link = " &lt;a href=\"http://" + tokens[i] + "\"&gt;" + tokens[i] + "&lt;/a&gt; ";
                  sbStr.append(link);
              } else if ((tokens[i]).contains("http://")) {
                  String link = " &lt;a href=\"" + tokens[i] + "\"&gt;" + tokens[i] + "&lt;/a&gt; ";
                  sbStr.append(link);
              } else {
                  sbStr.append(tokens[i] + " ");
              }
          }
          return Html.fromHtml(sbStr.toString());
      }
  </code></pre>
  
  <p>Java or android have any class for do this action without using my method?</p>