# File lib/fakefs/globber.rb, line 63
    def regexp(pattern)
      pattern = pattern.to_s

      regex_body = pattern.gsub('.', '\.')
                          .gsub('+') { '\+' }
                          .gsub('?', '.')
                          .gsub('*', '.*')
                          .gsub('(', '\(')
                          .gsub(')', '\)')
                          .gsub('$', '\$')

      # This matches nested braces and attempts to do something correct most of the time
      # There are known issues (i.e. {,*,*/*}) that cannot be resolved with out a total
      # refactoring
      loop do
        break unless regex_body.gsub!(/(?<re>\{(?:(?>[^{}]+)|\g<re>)*\})/) do
          "(#{Regexp.last_match[1][1..-2].gsub(',', '|')})"
        end
      end

      regex_body = regex_body.gsub(/\A\./, '(?!\.).')

      /\A#{regex_body}\Z/
    end