I am trying to find a way to let me dynamically create a regexp object from a string (taken from the database) and then use that to filter another string. This example is to extract data from a git commit message, but in theory any valid regexp could be present in the database as a string.
What happens
>> string = "[ALERT] Project: Revision ...123456 committed by Me <[email protected]>\n on 2009- 07-28 21:21:47\n\n Fixed typo\n"
>> r = Regexp.new("[A-Za-z]+: Revision ...[\w]+ committed by [A-Za-z\s]+")
>> string[r]
=> nil
What I want to happen
>> string = "[ALERT] Project: Revision ...123456 committed by Me <[email protected]>\n on 2009- 07-28 21:21:47\n\n Fixed typo\n"
>> string[/[A-Za-z]+: Revision ...[\w]+ committed by [A-Za-z\s]+/]
=> "Project: Revision 123456 committed by Me"