Searching for code on the web is always a bit tricky, as search engines tend to ignore or mangle punctuation and other characters that are central to programming. The latest bit from Google Labs, Google Code Search lets you search public source code, even using regexps.
Pardon me while I drool over this.
You can also limit your search by language, path or file names, package names and license (clever!).
- I hate my job
- (let your imagination run free for more)
The obligatory vanity search yielded a slightly surprising result from emacspeak. Huh. Oh, well.
"Public source code" seems to mean mostly packaged code available on the web or in publicly browsable cvs repositories. I hope they'll include code posted on blogs etc. in the future.
Code searching elsewhere
O'Reilly Code Search let's you search code snippets from nearly 700 O'Reilly books. Koders and Krugle both seem similar to Google Code Search, but I haven't had a closer look at any of them.
Update: Jason Kottke likes to play around, too.