I'm not sure what you're saying in either case.

```
# if the string contains any characters that are not in the printable character class
if string =~ /[^[:print:]]/
```

I don't see why you would want to anchor it, we want to look anywhere in the string.