Java List Create createMergedRegex(List regexes)

Here you can find the source of createMergedRegex(List regexes)

Description

create Merged Regex

License

Apache License

Declaration

public static String createMergedRegex(List<String> regexes) 

Method Source Code


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

import java.util.List;

public class Main {
    public static String createMergedRegex(List<String> regexes) {

        if (regexes == null) {
            return null;
        }/*from ww w.j  a  va  2 s . co m*/

        StringBuilder mergedRegexStringBuilder = new StringBuilder("");
        int regexCount = regexes.size();

        mergedRegexStringBuilder.append("(");

        for (int i = 0; i < regexCount; i++) {
            if ((i + 1) < regexCount) {
                mergedRegexStringBuilder.append(regexes.get(i)).append("|");
            } else {
                mergedRegexStringBuilder.append(regexes.get(i));
            }
        }

        mergedRegexStringBuilder.append(")");

        return mergedRegexStringBuilder.toString();
    }
}

Related

  1. createListWithArray(Object[] array)
  2. createListWithObjects(Object... objects)
  3. createMapFromList(List list)
  4. createMapOfObjects(List keys, List values)
  5. createMatrix(List source, List target)
  6. createMultiParamMessage(String aPrefix, String aSuffix, List aParams)
  7. createMultiSelectionValue(List values)
  8. createMutableList(Collection collection)
  9. createNewList(Class type)