208: Regular Expressions
Title text: Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee.
In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize) strings of text, such as particular characters, words, or patterns of characters.
Looking for a specific pattern on 200MB of text is an equivalent to "looking for a needle in a haystack" (Considering UTF-32 (32bits per character), this would be over 5 million characters. This task can be made easy by using "regexes", since they can find "match" a specific string pattern on the text.
Perl is a popular scripting language, and is especially well known for the flexible and simple regular expression features that it offers.
This comic is featured on one of the T-shirts sold at the xkcd store
- Narrator: Whenever I learn a new skill I concoct elaborate fantasy scenarios where it lets me save the day.
- Megan: Oh no! The killer must have followed her on vacation!
- [Megan points to computer]
- Megan: But to find them we'd need to search through 200MB of emails looking for something formatted like an address!
- Cueball: It's hopeless!
- Offpanel voice: Everybody stand back.
- Offpanel voice: I know regular expressions.
- [A man swings in on a rope, toward the computer]
- tap tap
- [The man swings away, and the other characters cheer]