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

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

Description

split And Trim

License

Apache License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static List<String> splitAndTrim(String s, String regex) {
        if (s == null) {
            return null;
        }/*from  w  ww. j a va  2 s. c om*/
        List<String> returnList = new ArrayList<>();
        for (String string : s.split(regex)) {
            returnList.add(string.trim());
        }

        return returnList;

    }
}

Related

  1. split(String input, String regex)
  2. split(String str, String regex)
  3. split(String str, String regex)
  4. split(String string, String pattern)
  5. split(String text, String pattern)
  6. splitList(String list, String splitRegex)
  7. splitNoEmpty(String sStr, String regex)
  8. splitString(String str, List list, String regex)
  9. splitStringToList(String input, String regex)