Is there an easy way in Bash to split a camelcased word into its constituent words?
For example, I want to split aCertainCamelCasedWord into 'a Certain Camel Cased Word' and be able to select those fields that interest me. This is trivially done with cut(1) when the word separator is the underscore, but how can I do this when the word is camelcased?
assertThat (findWordsInMixedCase ( "thisIsCamelCaseText" )) .containsExactly ( "this", "Is", "Camel", "Case", "Text" ); Here we see that the words are extracted from a camel case String and come out with their capitalization unchanged. For example, “Is” started with a capital letter in the original text, and is capitalized when extracted.
All letters in the first word are lowercase. For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase. Given a CamelCase sequence represented as a string.
Given a string in camel case, write a Python program to split each word in the camel case string into individual strings. A naive or brute-force approach to split CamelCase string to individual strings is to use for loop. First, use an empty list ‘words’ and append the first letter of ‘str’ to it.
CamelCase is the sequence of one or more than one words having the following properties: It is a concatenation of one or more words consisting of English letters. All letters in the first word are lowercase. For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase.
sed 's/\([A-Z]\)/ \1/g'
Captures each capital letter and substitutes a leading space with the capture for the whole stream.
$ echo "aCertainCamelCasedWord" | sed 's/\([A-Z]\)/ \1/g'
a Certain Camel Cased Word
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With