All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xxl.mathematica.string.StringSplit Maven / Gradle / Ivy

package xxl.mathematica.string;

import io.vavr.control.Try;

import java.util.Arrays;
import java.util.List;

/**
 * 分割字符串
 */
public class StringSplit {
    /**
     * 一个或多个分割符
     *
     * @param str
     * @param splitter
     * @return
     */
    public static List stringSplit(String str, String... splitter) {
        return Try.ofCallable(() -> {
            String split = StringRiffle.stringRiffle(Arrays.asList(splitter), "|");
            String[] a = str.split(split);
            return Arrays.asList(a);
        }).getOrNull();
    }

    /**
     * 默认空格分隔
     *
     * @param str
     * @return
     */
    public static List stringSplit(String str) {
        return stringSplit(str, " ");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy