Make a separator for a prose-like list with `,` between items except
    for `, and` after the second to last item.
1001
def _oxford_comma_separator(i, length):
    
    if length == 1:
        return None
    elif length < 3 and i == 0:
        return ' and '
    elif i < length - 2:
        return ', '
    elif i == length - 2:
        return ', and '
    else:
        return None
830897
function(a, b, separator) {
		separator || (separator = ' ');

		var lastCharA = a.slice(-1);
		var firstCharB = b.charAt(0);

		if (lastCharA == '' || firstCharB == '') {
			return a + b;
		}
		if (regexAlphaUnderscore.test(lastCharA)) {
			if (regexAlphaNumUnderscore.test(firstCharB)) {
				// e.g. `while` + `1`
				// e.g. `local a` + `local b`
				return a + separator + b;
			} else {
				// e.g. `not` + `(2>3 or 3<2)`
				// e.g. `x` + `^`
				return a + b;
			}
		}
		if (regexDigits.test(lastCharA)) {
			if (
				firstCharB == '(' ||
				!(firstCharB == '.' ||
				regexAlphaUnderscore.test(firstCharB))
			) {
				// e.g. `1` + `+`
				// e.g. `1` + `==`
				return a + b;
			} else {
				// e.g. `1` + `..`
				// e.g. `1` + `and`
				return a + separator + b;
			}
		}
		if (lastCharA == firstCharB && lastCharA == '-') {
			// e.g. `1-` + `-2`
			return a + separator + b;
		}
		var secondLastCharA = a.slice(-2, -1);
		if (lastCharA == '.' && secondLastCharA != '.' && regexAlphaNumUnderscore.test(firstCharB)) {
			// e.g. `1.` + `print`
			return a + separator + b;
		}
		return a + b;
	}
893245
public static String trim(String list, String delimiter) {
	return trim(list, delimiter, new int[2], false);
    }
219348
def string_to_list(string, sep=",", filter_empty=False):
    """"""
    return [value.strip() for value in string.split(sep)
            if (not filter_empty or value)]
1357229
def endBy1(p, sep):
    ''''''
    return separated(p, sep, 1, maxt=float('inf'), end=True)
923449
def comma_separated_positions(text):
    
    chunks = []
    start = 0
    end = 0
    for item in text.split(","):
        space_increment = 1 if item[0] == " " else 0
        start += space_increment  # Is there a space after the comma to ignore? ", "
        end += len(item.lstrip()) + space_increment
        chunks.append((start, end))
        start += len(item.lstrip()) + 1  # Plus comma
        end = start
    return chunks
748434
def join(strings: Optional[Sequence[str]], separator: str = "") -> str:
    
    return separator.join(s for s in strings if s) if strings else ""
776552
public static List<String> splitAndTrimAsList(String text, String sep) {
        ArrayList<String> answer = new ArrayList<>();
        if (text != null && text.length() > 0) {
            for (String v : text.split(sep)) {
                String trim = v.trim();
                if (trim.length() > 0) {
                    answer.add(trim);
                }
            }
        }
        return answer;
    }
813024
public static List<String> split(String string, String separator)
  {
    final int separatorLength = separator.length();
    final List<String> list = new ArrayList<String>();

    int fromIndex = 0;
    for(;;) {
      int endIndex = string.indexOf(separator, fromIndex);
      if(endIndex == -1) {
        break;
      }
      if(fromIndex < endIndex) {
        list.add(string.substring(fromIndex, endIndex).trim());
      }
      fromIndex = endIndex + separatorLength;
    }
    if(fromIndex < string.length()) {
      list.add(string.substring(fromIndex).trim());
    }
    return list;
  }
1318227
public static List<String> splitNicelyWithPattern( String toSplit, String patternSeparator ) {

		if( patternSeparator == null || patternSeparator.isEmpty())
			throw new IllegalArgumentException( "The separator cannot be null or the empty string." );

		List<String> result = new ArrayList<> ();
		if( ! Utils.isEmptyOrWhitespaces( toSplit )) {
			for( String s : toSplit.split( patternSeparator ))
				result.add( s .trim());
		}

		return result;
	}
946541
def _strip_line_sep(self, s):
        """"""
        if s[-2:] == b'\r\n':
            return s[:-2]
        elif s[-1:] == b'\n':
            return s[:-1]
        else:
            return s
662876
def _format_element(element, count, index, last_separator):
    
    return ("%s'%s'" % (last_separator, element)
            if count > 1 and index == count - 1
            else "'%s'" % (element,))
652330
public static List<String> split(String str, char separator, int limit, boolean isTrim, boolean ignoreEmpty){
		return split(str, separator, limit, isTrim, ignoreEmpty, false);
	}
1357556
def parse_list(text, off=0, trim=True):
    '''
    
    '''

    if not nextchar(text, off, '('):
        raise s_exc.BadSyntax(at=off, mesg='expected open paren for list')

    off += 1

    valus = []
    while off < len(text):

        _, off = nom(text, off, whites)

        valu, off = parse_valu(text, off)

        _, off = nom(text, off, whites)

        # check for foo=bar kw tuple syntax
        if nextchar(text, off, '='):

            _, off = nom(text, off + 1, whites)

            vval, off = parse_valu(text, off)

            _, off = nom(text, off, whites)

            valu = (valu, vval)

        valus.append(valu)

        _, off = nom_whitespace(text, off)

        if nextchar(text, off, ')'):
            return valus, off + 1

        if not nextchar(text, off, ','):
            raise s_exc.BadSyntax(at=off, text=text, mesg='expected comma in list')

        off += 1

    raise s_exc.BadSyntax(at=off, mesg='unexpected and of text during list')
1250668
def sepBy(p, sep):
    ''''''
    return separated(p, sep, 0, maxt=float('inf'), end=False)
162241
public static String format( Collection<String> items, String separator ) {

		StringBuilder sb = new StringBuilder();
		for( Iterator<String> it = items.iterator(); it.hasNext(); ) {
			sb.append( it.next());
			if( it.hasNext())
				sb.append( separator );
		}

		return sb.toString();
	}
1336513
def truncate_between(str, after = 30)
      str = '' if str.nil?
      str.length > after ? "#{str[0..(after / 2) - 2]}...#{str[(str.length - ((after / 2) - 2))..str.length]}" : str
    end