![]() They’re fast and simple and easy to read, and there’s a lot to be said for fast, simple, readable code. If your goal can be accomplished with string methods, you should use them. The replace() and split() methods have the same limitations. To do case-insensitive searches of a string s, you must call s.lower() or s.upper() and make sure your search strings are the appropriate case to match. For example, the index() method looks for a single, hard-coded substring, and the search is always case-sensitive. But these methods are limited to the simplest of cases. In Python, strings have methods for searching and replacing: index(), find(), split(), count(), replace(), &c. Getting a small bit of text out of a large block of text is a challenge. ❝ Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems. You are here: Home ‣ Dive Into Python 3 ‣ĭifficulty level: ♦♦♦♢♢ Regular Expressions
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |