208: Regular Expressions
explain xkcd: It's 'cause you're dumb.
| Regular Expressions |
![]() Title text: Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee. |
[edit] Explanation
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.
[edit] Trivia
This comic is featured on one of the T-shirts sold at the xkcd store
[edit] Transcript
- 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
- PERL!
- [The man swings away, and the other characters cheer]
Discussion
Hi, sorry about the previous "poor explanation". This one is pretty straight-forward (I think), given enough information about "regex"es and Perl. On a side-note, how did you find out the date for the comic? -- NariOx
![Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee.](/wiki/images/7/7b/regular_expressions.png)