Happy Valentine’s Day

Some Valentine's-Day-themed geekery from around the intertubes…


A Halo Valentine from II HYPNOTiiQ II and Xbox.com

Grunts are red; plasma grenades are blue. My Warthog has a seat that's open for you!

A hexadecimal / Zero Wing / Valentine / shirt
mashup from ThinkGeek

Roses are #FF0000; violets are #0000FF. All my base are belong to you.

Rosette Nebula


← The Rosette Nebula, Astronomy Picture of the Day for February 14, 2008, from Nasa.gov.

The Rosette Nebula (aka NGC 2237) is not the only cosmic cloud of gas and dust to evoke the imagery of flowers. But it is the one most often suggested as a suitable astronomy image for Valentine's Day.


Then there are heart surface and heart curve formulas from Wolfram MathWorld. And romantic Perl code poetry—geek love at its finest.

I guess my old expression of regex love is also appropriate here, if anywhere ↓

(you)?
(?(1)
	\u2665
	((?:reg(?:ular\s+expressions?|ex(?:p|e[ns])?))++)
|
	(?!)
)
(?>\1\2)

10 Reasons to Learn and Use Regular Expressions

10. Regular expressions are everywhere

Here's a short list of programming languages and tools that support regular expressions. The links are to their regex documentation.

9. Regular expression mastery can help you stand out from the crowd

Regular expressions might be everywhere, but many experienced programmers are intimidated by them. Knowing how to use regular expressions effectively is a valuable skill that can quickly make your peers take notice.

8. Wielding regular expressions can make you feel like a mighty wizard

Regular expressions can be difficult to master, but doing so is that much more rewarding as a result. Writing a line of cryptic letters and symbols that does what might otherwise take hundreds of lines of code can feel pretty cool.

7. If your search is simple, regular expression syntax is simple

Want to match the word "cat"? The regex is simply cat. ^cat matches "cat" at the beginning of the string, cat$ matches at the end, and cat|dog matches "cat" or "dog". Most regex syntax is very simple once you get the hang of it.

6. Regular expressions are portable

That's a bold lie, yet it's usually true for people who stick to the basics or intentionally write their regexes in a portable way. The majority of regex syntax works the same in a wide variety of programming languages and tools.

5. Regular expressions can help you write short code

This can be especially helpful in JavaScript, where keeping code length down is important for people with slow Internet connections. And although regexes can be hard to read, I'd rather spend a minute stepping through the logic of a regex than doing the same thing with a page full of code. Of course, like with most things in life it's important to find a good balance.

4. Regular expressions save time

Even for newcomers who still struggle with the syntax, regular expressions are often the fastest way to get the job done.

3. Regular expressions are fast

Although typical backtracking regex engines have so-called pathological cases which can take a very long time, regexes written with performance in mind will be fast enough for your needs in almost all cases. To ensure that's true, it's a good idea to at least get a feel for the basics of regex performance optimization.

2. Regular expressions can match just about anything

In other words, regular expressions are powerful. A regular expression guru can find many appropriate uses for regexes where the untrained user might not think to look. As the authors of Programming Perl wrote, "if you take 'text' in the widest possible sense, perhaps 90% of what you do is 90% text processing."

1. Regular expressions are fun

Like any good challenge, regexes can be a lot of fun. Tools like RegexPal can help remove a lot of the guesswork, so you can concentrate on solving problems.

… Feel free to add your own reasons why you think regexes are awesome^2 or the worst idea since unicycles.

Update: This post has been translated into Portuguese (by Fábio Luciano) and Spanish (by Fernando Briano). Thanks guys!