in reply to cgi search all txt files in a directory
Before you put this on a user-facing server, consider all the creative ways folks could abuse your server by putting clever things in your regex. You might want to look into quotemeta.