django-utils v0.3.0 documentation

This Page

Strings

A collection of utilities for dealing with strings.

djutils.utils.strings.split_words_at(words, split_at, after=True)

Split the words string at a certain number of characters

Parameters:
  • words – an arbitrary string to truncate
  • split_at – number of characters to treat as the boundary
  • after – whether to break up string before or after the boundary

Example:

>>> split_words_at('aa bb cc dd', 4, True)
'aa bb'
>>> split_words_at('aa bb cc dd', 4, False)
'aa'
djutils.utils.strings.clean_stop_words(text)

Remove all instances of stop words from text. Stop words are defined in djutils.constants