module SimpleJSONSchema::RegexHelper

Constants

RUBY_REGEX_ANCHORS_TO_ECMA_262

Public Class Methods

ecma_262_regex(pattern, cache) click to toggle source
# File lib/simple_json_schema/regex_helper.rb, line 13
def ecma_262_regex(pattern, cache)
  cache.fetch(pattern) do
    Regexp.new(
      Regexp::Scanner.scan(pattern).map do |type, token, text|
        type == :anchor ? RUBY_REGEX_ANCHORS_TO_ECMA_262.fetch(token, text) : text
      end.join
    )
  end
end