Skip to content

truncateExpect

The string ignores truncation until the ending character (endStringChar). If the expected length is reached, return the truncated string until after the ending character.

Parameters

NameTypeRequiredDefault
strstring
expectLengthnumber
endStringCharnamedstring'.'

named parameters are passed as named parameters in Dart and keyword arguments in Python.

Returns

string

Examples

javascript
truncateExpect('hello. this is test string.', 10, '.'); // Returns 'hello. this is test string.'
truncateExpect('hello-this-is-test-string-bye', 14, '-'); // Returns 'hello-this-is-'
dart
truncateExpect('hello. this is test string.', 10, endStringChar: '.'); // Returns 'hello. this is test string.'
truncateExpect('hello-this-is-test-string-bye', 14, endStringChar: '-'); // Returns 'hello-this-is-'
python
truncateExpect('hello. this is test string.', 10, '.')  # Returns 'hello. this is test string.'
truncateExpect('hello-this-is-test-string-bye', 14, '-')  # Returns 'hello-this-is-'

Released under the MIT License