I have a simple requirement. I read a string from user( either track or trAck). I want a logic using Regexp concept which will check this user input against a regular expression (within a string) :
def test_regex
string = "tr[Aa]ck"
string1 = /#{Regexp.quote(string)}/ #tried something here
user_input = "track" #or "trAck"
if string1 == user_input
puts "REGEX works"
else
puts "DIDN work"
end
end
end
I know I have blindly written some code. Need the right direction!