Home > Articles > Programming > Python

  • Print
  • + Share This
From the author of

Using Regular Expressions

Regular expressions provide much more powerful string search tools than simple text strings. Using sequences of letters, anchors, and wildcards, we can find a greatly increased range of substrings. However, regular expressions also provide other facilities for combining optional expressions and repetitions; you should look into these, too, for even more power and flexibility.

We've seen a little of what regular expressions look like, but what can we do with them? We can use them as very powerful search tools in text. We can look for lots of different variations of text strings in a single operation, and we can even search for nonprintable characters such as blank lines using some of the metacharacters available. Regular expressions are not a panacea for all textual programming problems; they can be fooled by recursive and nested text structures, and for these situations you must parse the input character by character. But for many day-to-day text processing situations, regular expressions are the ideal tool.

  • + Share This
  • 🔖 Save To Your Account