How do I match something that is not a letter or a number or a space?

Viewed 105

I'm using Ruby 2.4. How do I match something that is not a letter or a number or a space? I tried

2.4.0 :004 > str = "-"
 => "-"
2.4.0 :005 > str =~ /[^[:alnum:]]*/
 => 0
2.4.0 :006 > str = " "
 => " "
2.4.0 :007 > str =~ /[^[:alnum:]]*/
 => 0

but as you can see it is still matching a space.

1 Answers
Related