Limit Word
@param  String
@param  Integer
@return String
970435
public static function limitWord($string, $word_limit)
    {
        $words = explode(" ", $string);
        return implode(" ", array_splice($words, 0, $word_limit));
    }
1270482
public static function truncate(string $string, int $maxLength, string $indicator = '...'): string
    {
        if (mb_strlen($string) > $maxLength) {
            $string = mb_substr($string, 0, $maxLength - mb_strlen($indicator)) . $indicator;
        }

        return $string;
    }
380112
function replace($old, $new, $limit = null) {
		$old = self::toNativeString ( $old );
		$new = self::toNativeString ( $new );
		$oldLength = strlen ( $old );
		$newLength = strlen ( $new );
		$string = $this->string;
		$offset = 0;
		for ($i = 0; $limit === null || $i < $limit; $i ++) {
			$position = strpos ( $string, $old, $offset );
			if ($position === false) {
				break;
			}
			$string = substr_replace ( $string, $new, $position, $oldLength );
			$offset += $position + $newLength;
		}
		return new self ( $string );
	}
112427
protected function getLimitString(): string
    {
        $statement = '';
        $limit     = $this->builder->getLimit();
        if (!$limit) {
            return $statement;
        }

        $isUpdateOrDelete = $this->isDelete() || $this->isUpdate();
        if ($isUpdateOrDelete && $limit['limit']) {
            return sprintf('LIMIT %d', $limit['limit']);
        }

        $size      = $limit['limit'];
        $offset    = $limit['offset'];
        $statement = sprintf('LIMIT %d,%d', $offset, $size);

        return $statement;
    }
607130
protected function limitConsecutiveNewlines($string, $limit = 2)
    {
        // Pattern that finds any consecutive newlines that exceed the allowed limit.
        $exceeded = $limit + 1;
        $pattern = '/((\\n){' . $exceeded . ',})/';

        // Create a string with the maximum number of allowed newlines.
        $newlines = '';
        for ($i = 0; $i < $limit; $i++) {
            $newlines .= PHP_EOL;
        }

        // Find each match and replace it with the maximum number of newlines.
        return preg_replace($pattern, $newlines, $string);
    }
35359
public function getLimitString($includeText = true)
    {
        $statement = "";

        if (!$this->limit) {
            return $statement;
        }

        $statement .= $this->limit['limit'];

        if ($this->limit['offset'] !== 0) {
            $statement .= " OFFSET " . $this->limit['offset'];
        }

        if ($includeText && $statement) {
            $statement = "LIMIT " . $statement;
        }

        return $statement;
    }
1156938
private static String toBinaryString(int word)
  {
    String lsb = Integer.toBinaryString(word);
    StringBuilder pad = new StringBuilder();
    for (int i = lsb.length(); i < 32; i++) {
      pad.append('0');
    }
    return pad.append(lsb).toString();
  }
957732
function limitPath($file)
    {
        $x = explode('/', $file);
        $l = count($x);
        return ($l>1) ? $x[$l-2] . '/' . $x[$l-1] : $file;
    }
591886
public static function limit( $value, $limit = 100, $end = '...' )
    {
        if ( mb_strlen( $value ) <= $limit )
        {
            return $value;
        }

        return rtrim( mb_substr( $value, 0, $limit, 'UTF-8' ) ) . $end;
    }
848704
public function limitChar($content, $limit = 100)
    {
        if (strlen($content) <= $limit) {
            return $content;
        } else {
            $hasil = substr($content, 0, $limit);
            return $hasil . "...";
        }
    }
440819
public static function shorten($string, $limit = 25, $glue = ' &hellip; ') {
        if (mb_strlen($string) > $limit) {
            $width = round($limit / 2);

            // prefix
            $pre = mb_substr($string, 0, $width);

            if (mb_substr($pre, -1) !== ' ' && ($i = static::lastIndexOf($pre, ' '))) {
                $pre = mb_substr($pre, 0, $i);
            }

            // suffix
            $suf = mb_substr($string, -$width);

            if (mb_substr($suf, 0, 1) !== ' ' && ($i = static::indexOf($suf, ' '))) {
                $suf = mb_substr($suf, $i);
            }

            return trim($pre) . $glue . trim($suf);
        }

        return $string;
    }
15660
protected function wordWrap(string $string, int $width): string
	{
		return trim(preg_replace(sprintf('/(.{1,%1$u})(?:\s|$)|(.{%1$u})/uS', $width), '$1$2' . PHP_EOL, $string));
	}
985028
private String limitString() {
        if(params.length != 2){
            throw new IllegalArgumentException("Wrong number of Parameters for limit string expression");
        }

        final String field = record.getValueByFieldName(params[0]);
        int limit = Integer.parseInt(params[1]);

        if (field.isEmpty() || field.length() < limit){
            return field;
        }

        String result = field.substring(0, limit) + "...";
        return result;
    }
912062
public final function limit($limit): ?string
    {
        if (is_array($limit)) {
            @ [$limit, $offset] = array_map('abs', $limit);

            return ($offset !== null) ? 'LIMIT '. $limit .' OFFSET '. $offset : 'LIMIT '. $limit;
        }

        if ($limit || $limit === 0 || $limit === '0') {
            return 'LIMIT '. abs($limit);

        }

        return null;
    }
794628
public static function getLimitString($limit)
    {
        if (isset($limit) && !empty($limit)) {
            $limitParts = GeneralUtility::trimExplode(',', $limit);
            if (count($limitParts) === 1) {
                return intval($limitParts[0]);
            }
            if (count($limitParts) === 2) {
                return intval($limitParts[0]) . ',' . intval($limitParts[1]);
            }
        }

        return '';
    }
486915
public static function trim_to_nearest_word( $text, $char_limit ) {
		if ( strlen( $text ) <= $char_limit ) {
			return $text;
		}

		$wrapped_text = explode( '\n', wordwrap( $text , $char_limit, '\n' ) );

		return is_array( $wrapped_text ) ? $wrapped_text[0] : substr( $text, 0, $char_limit );
	}
716961
def _limit(lower, upper):
    """"""
    if ((lower < 0) or (upper <= 0) or (upper < lower)):
        raise Exception("Illegal argument to _limit")
    return unicod("{%d,%d}") % (lower, upper)