Google Labs has deployed Google Code Search, which allows regular expressions to be used to search public source code on the Internet. You can also restrict searches by language, license or filename. Earlier this year, Krugle launched a source code search engine, too. I'll need to think about the potential IP, license and security implications of this (there are many software licenses being used in the world, so how do they respect those that don't allow republication, for example, or what if they don't detect a license in the crawl?), but I suppose if it's out there, it's out there. At any rate, it's interesting what you can do. I bet a lot of people will get a lot of mileage out of this:

Google Code Search for: hello world
Google Code Searches for: dasblog and dasBlog" target=_blank>dasBlog
Google Code Search for: lifetheuniverseandeverything

  • Google Code Searches for: a couple not-safe-for-work vulgar words (hmmm)

Google crawls as much publicly accessible source code as their system can find, including archives (.tar.gz, .tar.bz2, .tar, and .zip), CVS repositories and Subversion repositories. And there's also a GData API available to allow mashup apps access to the functionality.

**Syntax and Examples **(more about regexp syntax)

*regexp*****Search for a regular expresion
go{2}gle hello,\ world ^int printk

"exact string"****Search for exact string
"compiler happy"

file:*regexp*****Search only in files or directories matching regexp
file:.js$ XMLHttpRequest file:include/ ioctl
file:/usr/sys/ken/slp.c "You are not expected to understand this."

package:*regexp*****Search packages with names matching regexp.
(A package's name is its URL or CVS server information.)
package:perl Frodo package:linux-2.6 int\ printk

lang:*regexp*****Search only for programs written in languages matching regexp
lang:lisp xml lang:"c++" sprintf.*%s

license:*regexp*****Search only for files with licenses matching regexp.
license:bsd int\ printf -license:gpl quicksort

(via Google Blogoscoped)