luna.util.stringcase module¶
Functions to convert strings.
- alphanumcase(string)[source]¶
Cuts all non-alphanumeric symbols, i.e. cuts all expect except 0-9, a-z and A-Z.
- Parameters
string (str) – String to convert.
- Returns
string – String with cutted non-alphanumeric symbols.
- Return type
- backslashcase(string)[source]¶
Convert string into spinal case. Join punctuation with backslash.
- Parameters
string (str) – String to convert.
- Returns
string – Spinal cased string.
- Return type
- camelcase(string)[source]¶
Convert string into camel case.
- Parameters
string (str) – String to convert.
- Returns
string – Camel case string.
- Return type
- capitalcase(string)[source]¶
Convert string into capital case. First letters will be uppercase.
- Parameters
string (str) – String to convert.
- Returns
string – Capital case string.
- Return type
Examples
>>> import luna.util.stringcase as sc >>> new_str = sc.camelcase("This is an interesting example.") >>> print(new_str) 'this is an interesting example.'
- constcase(string)[source]¶
Convert string into upper snake case. Join punctuation with underscore and convert letters into uppercase.
- Parameters
string (str) – String to convert.
- Returns
string – Const cased string.
- Return type
- dotcase(string)[source]¶
Convert string into dot case. Join punctuation with dot.
- Parameters
string (str) – String to convert.
- Returns
string – Dot cased string.
- Return type
- lowercase(string)[source]¶
Convert string into lower case.
- Parameters
string (str) – String to convert.
- Returns
string – Lowercase case string.
- Return type
Examples
>>> import luna.util.stringcase as sc >>> new_str = sc.camelcase("This is an Interesting EXAMPLE.") >>> print(new_str) 'this is an interesting example.'
- pascalcase(string)[source]¶
Convert string into pascal case.
- Parameters
string (str) – String to convert.
- Returns
string – Pascal case string.
- Return type
- pathcase(string)[source]¶
Convert string into path case. Join punctuation with slash.
- Parameters
string (str) – String to convert.
- Returns
string – Path cased string.
- Return type
- sentencecase(string)[source]¶
Convert string into sentence case. First letter capped and each punctuations are joined with space.
- Parameters
string (str) – String to convert.
- Returns
string – Sentence cased string.
- Return type
- snakecase(string)[source]¶
Convert string into snake case. Join punctuation with underscore.
- Parameters
string (str) – String to convert.
- Returns
string – Snake cased string.
- Return type
- spinalcase(string)[source]¶
Convert string into spinal case. Join punctuation with hyphen.
- Parameters
string (str) – String to convert.
- Returns
string – Spinal cased string.
- Return type
- titlecase(string)[source]¶
Convert string into sentence case. First letter capped while each punctuations is capitalsed and joined with space.
- Parameters
string (str) – String to convert.
- Returns
string – Title cased string.
- Return type
- trimcase(string)[source]¶
Convert string into trimmed string.
- Parameters
string (str) – String to convert.
- Returns
string – Trimmed case string.
- Return type
Examples
>>> import luna.util.stringcase as sc >>> new_str = sc.camelcase(" This is an Interesting EXAMPLE. ") >>> print(new_str) 'This is an Interesting EXAMPLE.'
- uppercase(string)[source]¶
Convert string into upper case.
- Parameters
string (str) – String to convert.
- Returns
string – Uppercase case string.
- Return type
Examples
>>> import luna.util.stringcase as sc >>> new_str = sc.camelcase("This is an Interesting EXAMPLE.") >>> print(new_str) 'THIS IS AN INTERESTING EXAMPLE.'