module EcmaReValidator
Constants
- INVALID_REGEXP
- INVALID_TOKENS
- UNICODE_CHARACTERS
JS doesn’t have Unicode matching
- VERSION
Public Class Methods
valid?(input)
click to toggle source
# File lib/ecma-re-validator.rb, line 30 def self.valid?(input) if input.is_a? String begin input = Regexp.new(input) rescue RegexpError return false end elsif !input.is_a? Regexp return false end Regexp::Scanner.scan(input).none? do |t| if t[1] == :word || t[1] == :space || t[1] == :digit t[0] != :type else INVALID_TOKENS.include?(t[1]) end end end