pyhelpers.text.extract_words1upper(x, join_with=None)

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

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

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


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 or str


>>> 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'