There are two ways to interpret this question, and the answer changes completely depending on which one you mean.
Deleting files by filename
If you want to nuke every file whose name contains a particular string:
find . -type f -name '*string*' -delete
The -type f keeps it from touching directories. The -delete flag removes whatever find matches. Simple enough.
A word of caution: test without -delete first. Run the same command and replace it with -print to see what would actually get deleted. I’ve lost files to typos in wildcard patterns more times than I care to admit.
Deleting files by content
If you actually mean files that contain a string somewhere inside them, it’s a different problem entirely. You need to search the file contents, not just the filename:
grep -rl 'string' . | xargs rm
grep -r searches recursively, -l prints only the filenames of matches, and xargs rm deletes them.
This has its own gotchas. Filenames with spaces or special characters will break xargs rm unless you use the null-delimited variant:
grep -rlZ 'string' . | xargs -0 rm
The -Z flag makes grep output null-terminated filenames, and -0 tells xargs to split on nulls instead of whitespace.
A safer approach
If you’re feeling cautious, pipe through less first to inspect what’s actually going to be deleted:
grep -rl 'string' . | less
Or use find with -exec instead of xargs:
find . -type f -exec grep -l 'string' {} + -delete
This runs grep on batches of files and deletes only the matches, all in one command. No pipeline to break on weird filenames.
The short version
Know what you’re actually trying to delete — filename or content — and always preview before you commit. The difference between a useful command and a regrettable one is usually a single flag.