I have a hash with several keys and a string that contains none, none of the keys in the hash.
h = {"k1"=>"v1", "k2"=>"v2", "k3"=>"v3"} s = "this is an example string that might occur with a key somewhere in the string k1(with special characters like (^&*$#@!^&&*))"
What would be the best way to check if s contains any of the keys in h , and if so, return the value of the key that it contains?
For example, for the above examples of h and s output should be v1 .
Edit: only the string will be user defined. The hash will always be the same.
source share