Editing 208: Regular Expressions
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 4: | Line 4: | ||
| title = Regular Expressions | | title = Regular Expressions | ||
| image = regular_expressions.png | | image = regular_expressions.png | ||
− | | titletext = Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee | + | | titletext = Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee. |
}} | }} | ||
==Explanation== | ==Explanation== | ||
− | |||
− | + | In computing, a {{w|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". But this task can be made easy by using "regexes", since this script can find a "match", a specific string pattern, much faster than humans can achieve. | ||
+ | |||
+ | {{w|Perl}} is a popular scripting language, and is especially well known for the flexible and simple regular expression features that it offers. | ||
+ | |||
+ | The title text explains how sensitive the response is to small missing characters. | ||
==Transcript== | ==Transcript== | ||
− | |||
:Whenever I learn a new skill I concoct elaborate fantasy scenarios where it lets me save the day. | :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: Oh no! The killer must have followed her on vacation! | ||
:[Megan points to computer.] | :[Megan points to computer.] | ||
− | :Megan: But to find them we'd | + | :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! | :Cueball: It's hopeless! | ||
− | + | :Everybody stand back. | |
− | + | :I know regular expressions. | |
− | |||
− | |||
− | |||
:[A man swings in on a rope, toward the computer.] | :[A man swings in on a rope, toward the computer.] | ||
− | |||
:''tap tap'' | :''tap tap'' | ||
− | : | + | :''PERL!'' |
− | |||
:[The man swings away, and the other characters cheer.] | :[The man swings away, and the other characters cheer.] | ||
==Trivia== | ==Trivia== | ||
− | This comic | + | *This comic is featured on one of the [http://shop.xkcd.com/products/i-know-regular-expressions T-shirts] sold at the xkcd store. |
+ | *[[Randall]] no longer likes Perl, having discovered {{w|Python}}. | ||
+ | *Writing a good street address finder in regular expressions is a difficult task, especially internationally. [http://regexlib.com/Search.aspx?k=street Examples.] | ||
{{comic discussion}} | {{comic discussion}} | ||
− | |||
[[Category:Comics featuring Cueball]] | [[Category:Comics featuring Cueball]] | ||
[[Category:Comics featuring Megan]] | [[Category:Comics featuring Megan]] | ||
[[Category:Comics with color]] | [[Category:Comics with color]] | ||
− | [[Category: | + | [[Category:Programming]] |
− |