Skip to content

Text

String Module for dost.This module contains functions for working with strings.

Examples:

>>> from dost import text
>>> text.get_alphabets(text="hello123:l;,")
'hellol'
>>> text.get_numbers(text="hello123:l;,")
'123
>>> text.remove_special_characters(text="hello123:l;,")
'hello123l'

The module contains the following functions:

  • get_alphabets(text): Extract only alphabets from the given string.
  • get_numbers(text): Extract only numbers from the given string.
  • remove_special_characters(text): Remove special characters from the given string.

get_alphabets(text)

Extracts alphabets from the given string.

Parameters:

Name Type Description Default
text str

The string from which alphabets are to be extracted.

required

Returns:

Name Type Description
str str

Alphabets from the given string.

Examples:

>>> text.get_alphabets(text="hello123:l;,")
'hellol'

get_numbers(text)

Extracts alphabets from the given string.

Parameters:

Name Type Description Default
text str

The string from which numbers are to be extracted.

required

Returns:

Name Type Description
str str

Numbers extracted from the given string.

Examples:

>>> text.get_numbers(text="hello123:l;,")
'123'

remove_special_characters(text)

Removes special characters from the given string.

Parameters:

Name Type Description Default
text str

The string from which special characters are to be removed.

required

Returns:

Name Type Description
str str

The string without special characters.

Examples:

>>> text.extract_only_alphabets(text="hello123:l;,")
'hello123l'