Yep, this is an oldie, but I was also wanting to do a similar thing.
Not sure when it was introduced, but there is a Regexp.compile command that solves your/our problem.
File contents (eg.yaml):
---
my_regexp: ^feature\/
Example code:
require 'yaml'
config = YAML.load_file('eg.yaml')
rgx = Regexp.compile(config['my_regexp'])
puts 'No output, as it does not match' if 'hotfix/FU-123' =~ rgx
puts 'No output, as it starts with something different' if 'new_feature/FU-123' =~ rgx
puts 'Winner winner, chicken dinner' if 'feature/BAR-123' =~ rgx
As Andrew Grimm points out, it is possible to serialise the YAML to include hints. I personally find this to be problematic with config files that can be edited by humans.