Returns a substring of this.
@param start the position of first code point
@param until the position after last code point, exclusive.
768520
public UTF8String substring(final int start, final int until) {
    if (until <= start || start >= numBytes) {
      return EMPTY_UTF8;
    }

    int i = 0;
    int c = 0;
    while (i < numBytes && c < start) {
      i += numBytesForFirstByte(getByte(i));
      c += 1;
    }

    int j = i;
    while (i < numBytes && c < until) {
      i += numBytesForFirstByte(getByte(i));
      c += 1;
    }

    if (i > j) {
      byte[] bytes = new byte[i - j];
      copyMemory(base, offset + j, bytes, BYTE_ARRAY_OFFSET, i - j);
      return fromBytes(bytes);
    } else {
      return EMPTY_UTF8;
    }
  }
1189784
private static String prefix(String s, int start) {
        StringBuilder prefix=new StringBuilder(MAX_PREFIX_LENGTH+20);
        if(start==0) {
            prefix.append("\"");
        } else {
            prefix.append("[at pattern index ").append(start).append("] \"");
        }
        int substringLength=s.length()-start;
        if(substringLength<=MAX_PREFIX_LENGTH) {
            prefix.append(start==0 ? s : s.substring(start));
        } else {
            int limit=start+MAX_PREFIX_LENGTH-4;
            if(Character.isHighSurrogate(s.charAt(limit-1))) {
                // remove lead surrogate from the end of the prefix
                --limit;
            }
            prefix.append(s, start, limit).append(" ...");
        }
        return prefix.append("\"").toString();
    }
389235
public StringGrabber substring(int startIdx, int endIndex) {
		if (startIdx < 0) {
			startIdx = 0;
		}
		if (endIndex > length() - 1) {
			endIndex = length() - 1;
		}

		sb = new StringBuilder(substringInternally(startIdx, endIndex));
		return StringGrabber.this;
	}
760799
public function substring($start, $end = null)
    {
        if ($end === null) {
            return substr($this->content, $start);
        }
        $len = $end - $start;
        if ($len < 0) {
            return '';
        }
        return substr($this->content, $start, $len);
    }
293723
public static int getWhiteSpaceLineStartBefore( String script, int start )
  {
    int startLine = getLineStart( script, start );
    if( startLine > 0 )
    {
      int nextLineEnd = startLine - 1;
      int previousLineStart = getLineStart( script, nextLineEnd );
      boolean whitespace = GosuStringUtil.isWhitespace( script.substring( previousLineStart, nextLineEnd ) );
      if( whitespace )
      {
        return previousLineStart;
      }
    }
    return -1;
  }
586503
public static String substringBefore(String text, char stopper) {
        int p = text.indexOf(stopper);
        return p < 0 ? text : text.substring(0, p);
    }
309143
private static final String getString(CharacterIterator text, int start, int length) {
        StringBuilder result = new StringBuilder(length);
        int offset = text.getIndex();
        text.setIndex(start);
        for (int i = 0; i < length; i++) {
            result.append(text.current());
            text.next();
        }
        text.setIndex(offset);
        return result.toString();
    }
809358
function substr($str,$start,$len=0) {
		if ($start<0)
			$start=$this->strlen($str)+$start;
		if (!$len)
			$len=$this->strlen($str)-$start;
		return preg_match('/^.{'.$start.'}(.{0,'.$len.'})/us',$str,$match)?
			$match[1]:FALSE;
	}
1054896
public static function substring($string, $start = 0, $length = null)
    {
        if (!self::isValid($string)) {
            return false;
        }

        return mb_substr($string, $start, $length);
    }
1276576
public static final Function<String, Boolean> startsWith(final String prefix, final int offset) {
        return new StartsWith(prefix, offset);
    }
33589
public static function substr(string $string, int $start, int $length = null)
    {
        if ($length === 0) {
            return '';
        }

        // Cannot omit $length, when specifying charset
        if ($length === null) {
            // save internal encoding
            $enc = mb_internal_encoding();
            mb_internal_encoding('UTF-8');
            $str = mb_substr($string, $start);
            // restore internal encoding
            mb_internal_encoding($enc);

            return $str;
        }

        return mb_substr($string, $start, $length, 'UTF-8');
    }
424374
public static String[] between(final String value, final String start, final String end) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        validate(start, NULL_STRING_PREDICATE, () -> "'start' should be not null.");
        validate(end, NULL_STRING_PREDICATE, () -> "'end' should be not null.");

        String[] parts = value.split(end);
        return Arrays.stream(parts)
                .filter(subPart -> subPart.contains(start))
                .map(subPart -> subPart.substring(subPart.indexOf(start) + start.length()))
                .toArray(String[]::new);
    }
903329
public static String join(String start, String linePrefix, Collection<?> lines) {
        if (lines.isEmpty()) {
            return "";
        }
        StringBuilder out = new StringBuilder(start);
        for (Object line : lines) {
            out.append(linePrefix).append(line).append("\n");
        }
        return out.substring(0, out.length() - 1); //lose last EOL
    }
1339956
public HSlicePredicate<N> setStartOn(N start) {
    this.start = start;
    predicateType = PredicateType.Range;
    return this;
  }
1122407
@Override
    public String getString(long start, int length)
    {
        if (length == 0)
        {
            return "";
        }
        if (array != null)
        {
            int ps = (int) (start % size);
            int es = (int) ((start+length) % size);
            if (ps < es)
            {
                return new String(array, ps, length);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.append(array, ps, size-ps);
                sb.append(array, 0, es);
                return sb.toString();
            }
        }
        else
        {
            StringBuilder sb = new StringBuilder();
            for (int ii=0;ii<length;ii++)
            {
                sb.append((char)get(start+ii));
            }
            return sb.toString();
        }
    }
704162
async def substr(self, name, start, end=-1):
        
        return await self.execute_command('SUBSTR', name, start, end)
1270543
private static String trimSpaceAtStart(final String temp, final String termName) {
        if (termName != null && termName.charAt(termName.length() - 1) == ' ') {
            if (temp.charAt(0) == ' ') {
                return temp.substring(1);
            }
        }
        return temp;
    }