Lesson 8. Advanced string operations
After reading lesson 8, you’ll be able to
- Manipulate substrings
- Do mathematical operations with strings
If you’re given a long file, it’s typical to read the entire file as one large string. But working with such a large string can be cumbersome. One useful thing you might do is break it into smaller substrings—most often, by new lines, so that every paragraph or every data entry could be looked at separately. Another beneficial thing is to find multiple instances of the same word. You could decide that using the word very more than 10 times is annoying. Or if you’re reading the transcript of someone’s award acceptance speech, you may want to find all instances of the word like and remove those before posting ...
Get Get Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.