Splitting a string is something I find myself doing often. The split method is used for this:
We can choose the point that we split it at:
Rejoining our split string can be done using the join method:
We can play around with the case of letters in our string, too. Let's make it all upper case:
Now let's make it lowercase:
Let's capitalize only the first letter of the lowercase string:
We can also use the title method. This capitalizes the first letter in each word:
Trading case is possible:
We can run a number of tests on strings using a few methods. Let's check to see whether a given string is all upper case:
Likewise, we can check to see whether a string contains only lower case characters:
Checking whether a string looks like a title is simple, too:
blog comments powered by Disqus |