extract_words1upper

pyhelpers.text.extract_words1upper(x, join_with=None)[source]

Extract words from a string by spliting it at occurrence of an uppercase letter.

Parameters:
  • x (str) – a string joined by a number of words each starting with an uppercase letter

  • join_with (str | None) – a string with which to (re)join the single words, defaults to None

Returns:

a list of single words each starting with an uppercase letter, or a single string joined together by them with join_with

Return type:

list | str

Examples:

>>> from pyhelpers.text import extract_words1upper

>>> x1 = 'Network_Waymarks'
>>> x1_ = extract_words1upper(x1)
>>> x1_
['Network', 'Waymarks']

>>> x2 = 'NetworkRailRetainingWall'
>>> x2_ = extract_words1upper(x2, join_with=' ')
>>> x2_
'Network Rail Retaining Wall'