I want to read regular expressions from a external file in Ruby. For example, I want to substitute a big string loading every regex from a file and running gsub for each. Each regex is separated by newlines on the file.
The external file would be like this:
engenharia d[ae] computação
ci[êe]ncias? d[ae] computação
Is it possible?
Sure! You can create a regex simply by using
Regex.new "my string". To put it together with reading a file: