Ruby regex: replace non-word chars that are not space chars

regex, ruby

Solution

"the (quick)! brown \n fox".gsub(/[^\w\s]/, "#")

By making the regex replace anything that is NOT a word character OR a space character.

Problem

How do I replace all non-word chars (\W) that are also not space characters (\s)? This is the desired functionality: `"the (quick)! brown \n fox".gsub(regex, "#")` => `"the #quick## brown \n fox"`

Original source