Skip to main content

Regular Expressions

  • Chapter
Dive Into Python 3
  • 9456 Accesses

Abstract

Every modern programming language has built-in functions for working with strings. In Python, strings have methods for searching and replacing: index(), find(), split(), count(), replace(), and so on. But these methods are limited to the simplest of cases. For example, the index() method looks for a single, hard-coded substring, and the search is always case-sensitive. To do case-insensitive searches of a string s, you must call s.lower() or s.upper() and make sure that your search strings are the appropriate case to match. The replace() and split() methods have the same limitations.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Mark Pilgrim

About this chapter

Cite this chapter

Pilgrim, M. (2009). Regular Expressions. In: Dive Into Python 3. Apress. https://doi.org/10.1007/978-1-4302-2416-7_5

Download citation

Publish with us

Policies and ethics