Spaces to underscores

Hi all.

Is there a way to convert spaces to underscores?

turn “This is a string” to “This_is_a_string”

Thanks!