I accept the regular expression as input from the user and matching the values ββwith this regular expression. But the problem I have is that the input I get is a string. for example "/abc|def/i" And I cannot convert it to a regular expression object. If he tries Regexp.new(string) he avoids all the characters, so I get something like /\/abc|def\/i/
I managed to capture the part between the slash using another regular expression and build a regexp object with it. In the above example, I capture "abc|def" , and when I do Regexp.new("abc|def") , I get /abc|def/ , which I wanted, but I need to add regexp options too (for example, " i "in the above example) in string to the regexp ruby ββobject.
How can I achieve this?
In addition, there should be an easier way to achieve all this. Any help would be greatly appreciated.
Dipil source share