/^\s*function\s+(\w+)\s*\(/i # and then use hashes to save data so there's no s///