breakLine (lineOfText: string, maxLength: number): string[]
10757
function breakLine (lineOfText, maxLength) {
  const lines = []
  let currText = lineOfText

  while (currText) {
    if (currText.length <= maxLength) {
      lines.push(currText)
      break
    } else {
      let line = ''
      const words = currText.split(/\b/g)
      while (words.length && line.length + words[0].length < maxLength) {
        line += words.shift()
      }
      if (line) lines.push(line.trim())
      currText = words.join('')
    }
  }

  return lines
}
1208708
private String[] parseLine(String nextLine, boolean multi) {

    if (!multi && pending != null) {
      pending = null;
    }

    if (nextLine == null) {
      if (pending != null) {
        String s = pending;
        pending = null;
        return new String[] { s };
      } else {
        return null;
      }
    }

    List<String> tokensOnThisLine = new ArrayList<String>();
    StringBuilder sb = new StringBuilder(INITIAL_READ_SIZE);
    boolean inQuotes = false;
    if (pending != null) {
      sb.append(pending);
      pending = null;
      inQuotes = true;
    }
    for (int i = 0; i < nextLine.length(); i++) {

      char c = nextLine.charAt(i);
      if (format.isEscape(c)) {
        if (isNextCharacterEscapable(nextLine, inQuotes || inField, i)) {
          sb.append(nextLine.charAt(i + 1));
          i++;
        }
      } else if (c == format.getDelimiter()) {
        if (isNextCharacterEscapedQuote(nextLine, inQuotes || inField, i)) {
          sb.append(nextLine.charAt(i + 1));
          i++;
        } else {
          inQuotes = !inQuotes;

          // the tricky case of an embedded quote in the middle:
          // a,bc"d"ef,g
          if (!format.isStrictQuotes()) {
            if (i > 2 // not on the beginning of the line
                // not at the beginning of an escape
                // sequence
                && !format.isSeparator(nextLine.charAt(i - 1)) && nextLine.length() > (i + 1)
                // not at the end of an escape sequence
                && !format.isSeparator(nextLine.charAt(i + 1)) // not
            ) {
              // discard white space leading up to quote
              if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) {
                sb = new StringBuilder(INITIAL_READ_SIZE);
              } else {
                sb.append(c);
              }

            }
          }
        }
        inField = !inField;
      } else if (format.isSeparator(c) && !inQuotes) {
        tokensOnThisLine.add(sb.toString());
        sb = new StringBuilder(INITIAL_READ_SIZE); // start work on next
        // token
        inField = false;
      } else {
        if (!format.isStrictQuotes() || inQuotes) {
          sb.append(c);
          inField = true;
        }
      }
    }
    // line is done - check status
    if (inQuotes) {
      if (multi) {
        // continuing a quoted section, re-append newline
        sb.append("\n");
        pending = sb.toString();
        sb = null; // this partial content is not to be added to field
        // list yet
      } else {
        throw new RuntimeException("Un-terminated quoted field at end of CSV line");
      }
    }
    if (sb != null) {
      tokensOnThisLine.add(sb.toString());
    }
    return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]);

  }
861302
private static void validateLineBreaks(int[] linebreaks, int textLength) {
        int prev = 0;
        for (int i = 0; i < linebreaks.length; ++i) {
            int next = linebreaks[i];
            if (next <= prev) {
                throw new IllegalArgumentException("bad linebreak: " + next + " at index: " + i);
            }
            prev = next;
        }
        if (prev != textLength) {
            throw new IllegalArgumentException("last linebreak must be at " + textLength);
        }
    }
688253
private String[] jsSplit(String stringValue, String separator, int limit) {
    checkArgument(limit >= 0);
    checkArgument(stringValue != null);

    // For limits of 0, return an empty array
    if (limit == 0) {
      return new String[0];
    }

    // If a separator is not specified, return the entire string as
    // the only element of an array.
    if (separator == null) {
      return new String[] {stringValue};
    }

    List<String> splitStrings = new ArrayList<>();

    // If an empty string is specified for the separator, split apart each
    // character of the string.
    if (separator.isEmpty()) {
      for (int i = 0; i < stringValue.length() && i < limit; i++) {
        splitStrings.add(stringValue.substring(i, i + 1));
      }
    } else {
      int startIndex = 0;
      int matchIndex;
      while ((matchIndex =
          jsSplitMatch(stringValue, startIndex, separator)) >= 0 &&
          splitStrings.size() < limit) {
        splitStrings.add(stringValue.substring(startIndex, matchIndex));

        startIndex = matchIndex + separator.length();
      }

      if (splitStrings.size() < limit) {
        if (startIndex < stringValue.length()) {
          splitStrings.add(stringValue.substring(startIndex));
        } else {
          splitStrings.add("");
        }
      }
    }

    return splitStrings.toArray(new String[0]);
  }
1207931
public static String[] getDataFromLine(final String line, final String seperator,
		final boolean trim)
	{
		final StringTokenizer tokenizer = new StringTokenizer(line, seperator);
		final List<String> data = new ArrayList<>();
		while (tokenizer.hasMoreElements())
		{
			final String string = tokenizer.nextToken();
			if (trim)
			{
				data.add(string.trim());
			}
			else
			{
				data.add(string);
			}

		}
		final String[] splittedLine = data.toArray(new String[0]);
		return splittedLine;
	}
174990
private void skipToEndOfLine() throws IOException {
    while (pos < limit || fillBuffer(1)) {
      char c = buffer[pos++];
      if (c == '\n') {
        lineNumber++;
        lineStart = pos;
        break;
      } else if (c == '\r') {
        break;
      }
    }
  }
1056640
def max_line_length(text, separator)
      lines = text.split(separator, -1)
      display_width(lines.max_by { |line| display_width(line) } || '')
    end
773896
public static String maxLengthString(String... strings) {
        String res = "";
        for (String string : strings) {
            if (string.length() > res.length()) {
                res = string;
            }
        }
        return res;
    }
101456
private String getTextLine(String[] textLines, int line)
	{
		return (isIgnoreTrailingWhiteSpaces()) ? textLines[line].trim() : textLines[line];
	}
803906
public String[] getLine() throws IOException {
        String[] ret = EMPTY_STRING_ARRAY;
        record.clear();
        while (true) {
            reusableToken.reset();
            nextToken(reusableToken);
            switch (reusableToken.type) {
                case TT_TOKEN:
                    record.add(reusableToken.content.toString());
                    break;
                case TT_EORECORD:
                    record.add(reusableToken.content.toString());
                    break;
                case TT_EOF:
                    if (reusableToken.isReady) {
                        record.add(reusableToken.content.toString());
                    } else {
                        ret = null;
                    }
                    break;
                case TT_INVALID:
                default:
                    // error: throw IOException
                    throw new IOException("(line " + getLineNumber() + ") invalid parse sequence");
                // unreachable: break;
            }
            if (reusableToken.type != TT_TOKEN) {
                break;
            }
        }
        if (!record.isEmpty()) {
            ret = (String[]) record.toArray(new String[record.size()]);
        }
        return ret;
    }
737430
private int findLineBreak(Source source) {
        int index;
        int n = source.find(AbstractEol.AN, false);
        int r = source.find(AbstractEol.AR, false);
        if (n >= 0 && r >= 0) {
            index = Math.min(n, r);
        } else if (n >= 0) {
            index = n;
        } else if (r >= 0) {
            index = r;
        } else {
            index = -1;
        }
        return index;
    }
452050
def split(string, separator_regexp=None, maxsplit=0):
    
    if not string:
        return []
    if separator_regexp is None:
        separator_regexp = _default_separator()
    if not separator_regexp:
        return string.split()
    return re.split(separator_regexp, string, maxsplit)
744018
private String getRowLineBuf(int colCount, List<Integer> colMaxLenList, String[][] data) {
		
		S.Buffer rowBuilder = S.buffer();
		int colWidth;
		
		for (int i = 0 ; i < colCount ; i ++) {
			
			colWidth = colMaxLenList.get(i) + 3;
			
			for (int j = 0; j < colWidth ; j ++) {
				if (j==0) {
					rowBuilder.append("+");
				} else if ((i+1 == colCount && j+1 == colWidth)) {//for last column close the border
					rowBuilder.append("-+");
				} else {
					rowBuilder.append("-");
				}
			}
		}
		
		return rowBuilder.append("\n").toString();
	}
809464
public static String[] getDataFromLine(final String line, final String seperator)
	{
		final String[] splittedLine = line.split(seperator);
		return splittedLine;
	}
328424
function (parts, indent, prefix) {
        var lines = [];
        var line = [];

        var lineLength = !!prefix ? prefix.length - 1: indent.length - 1;

        parts.forEach(function (part) {
          if (lineLength + 1 + part.length > textWidth) {
            lines.push(indent + line.join(' '));
            line = [];
            lineLength = indent.length - 1;
          }
          line.push(part);
          lineLength += part.length + 1;
        });

        if (line) {
          lines.push(indent + line.join(' '));
        }
        if (prefix) {
          lines[0] = lines[0].substr(indent.length);
        }
        return lines;
      }
478729
def line_break(s, length=76):
    
    x = '\n'.join(s[pos:pos + length] for pos in range(0, len(s), length))
    return x
756539
public List<String> splitLimit(String str, String regex, int limit) {
		if (str == null || regex == null)
			return new ArrayList<String>();
		return Arrays.asList(str.split(regex, limit));
	}