extract_words1upper¶
- pyhelpers.text.extract_words1upper(x, join_with=None)[source]¶
Extract words from a string by splitting it at occurrences of uppercase letters.
This function takes a string and splits it into individual words wherever an uppercase letter is encountered. Optionally, it can join these words back into a single string using a specified delimiter.
- Parameters:
x (str) – Input text containing a number of words each starting with an uppercase letter.
join_with (str | None) – Optional delimiter used to join the extracted words into a single string; defaults to
None
.
- Returns:
If
join_with=None
, the function returns a list of words extracted fromx
where each word starts with an uppercase letter; ifjoin_with
is specified, it returns a single string where these words are joined byjoin_with
.- Return type:
list | str
Examples:
>>> from pyhelpers.text import extract_words1upper >>> extract_words1upper('Network_Waymarks') ['Network', 'Waymarks'] >>> extract_words1upper('NetworkRailRetainingWall', join_with=' ') 'Network Rail Retaining Wall'