Java String Split by Regex splitToList(String s, String regex)

Here you can find the source of splitToList(String s, String regex)

Description

split To List

License

Open Source License

Declaration

public static List<String> splitToList(String s, String regex) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> splitToList(String s, String regex) {
        List<String> list = new ArrayList<String>();
        for (String item : s.split(regex)) {
            if (!item.isEmpty()) {
                list.add(item);/*  w ww.  j  a  va 2s  .c o  m*/
            }
        }
        return list;
    }
}

Related

  1. splitList(String list, String splitRegex)
  2. splitNoEmpty(String sStr, String regex)
  3. splitString(String str, List list, String regex)
  4. splitStringToList(String input, String regex)
  5. splitTerms(String text, String pattern)
  6. splitToLongList(String str, String regex)