'/ asd / i' is a string. Why not make Regrexp? If you need to go from String to Regexp, one way to do this is to create a new Regexp object:
>> re = Regexp.new('/asd/i') => /\/asd\/i/ >> re = Regexp.new("asd", "i") => /asd/i
So maybe
>> str = gets.chomp #user inputs => "Hello World" re = Regexp.new(str, "i") => /Hello World/i
- this is what you are looking for.
But overall, I donβt think you can just βuse the string as a regular expression pattern,β although I am new to and probably wrong.
source share