class JsRegex::Converter::AnchorConverter
Template class implementation.
Constants
- BOUNDARY_EXPANSION
- NONBOUNDARY_EXPANSION
- W
This is an approximation to the word boundary behavior in Ruby, c.f. github.com/ruby/ruby/blob/08476c45/tool/enc-unicode.rb#L130
Private Instance Methods
convert_boundary()
click to toggle source
# File lib/js_regex/converter/anchor_converter.rb, line 23 def convert_boundary if context.es_2018_or_higher? && context.enable_u_option BOUNDARY_EXPANSION else pass_boundary_with_warning end end
convert_data()
click to toggle source
# File lib/js_regex/converter/anchor_converter.rb, line 11 def convert_data case subtype when :bol, :bos then '^' when :eol, :eos then '$' when :eos_ob_eol then '(?=\n?$)' when :word_boundary then convert_boundary when :nonword_boundary then convert_nonboundary else warn_of_unsupported_feature end end
convert_nonboundary()
click to toggle source
# File lib/js_regex/converter/anchor_converter.rb, line 31 def convert_nonboundary if context.es_2018_or_higher? && context.enable_u_option NONBOUNDARY_EXPANSION else pass_boundary_with_warning end end
pass_boundary_with_warning()
click to toggle source
# File lib/js_regex/converter/anchor_converter.rb, line 45 def pass_boundary_with_warning warn_of("The anchor '#{data}' at index #{expression.ts} only works "\ 'at ASCII word boundaries with targets below ES2018".') pass_through end