Here we take a look at the various methods of manipulating strings, covering things from basic methods to regular expressions.
The most basic way to manipulate strings is through the methods that are build into them. We can perform a limited number of tasks to strings through these methods. Let's create a string:
Let us count the number of characters in this string, i.e. we want to calculate its length. Use the function length():
Let's take our string and replace a word using the replace method:
To find a character or words, use "find". It finds the first occurrence of a given character or a word:
|Exercise: Replace the character "s" in the above example by "ng" and print the answer. Try other combinations as well|