$ grep -rl string1 somedir/ | xargs sed -i 's/string1/string2/g'
The above line will also modify files in hidden folders, such as files in .svn directories!
To avoid modifying files in .svn subdirs:
$ grep -rl string1 somedir/ | grep -v .svn | xargs sed -i 's/string1/string2/g'