watex.utils.funcutils.str2columns#

watex.utils.funcutils.str2columns(text, /, regex=None, pattern=None)[source]#

Split text from the non-alphanumeric markers using regular expression.

Remove all string non-alphanumeric and some operator indicators, and fetch attributes names.

Parameters
  • text (str,) – text litteral containing the columns the names to retrieve

  • regex (re object,) –

    Regular expresion object. the default is:

    >>> import re
    >>> re.compile (r'[#&*@!_,;\s-]\s*', flags=re.IGNORECASE)
    

  • pattern (str, default = ‘[#&*@!_,;s-]s*’) – The base pattern to split the text into a columns

Returns

attr

Return type

List of attributes

Examples

>>> from watex.utils.funcutils import str2columns
>>> text = ('this.is the text to split. It is an: example of; splitting str - to text.')
>>> str2columns (text )
... ['this',
     'is',
     'the',
     'text',
     'to',
     'split',
     'It',
     'is',
     'an:',
     'example',
     'of',
     'splitting',
     'str',
     'to',
     'text']