Module: MSFLVisitors::VisitorHelpers
- Defined in:
- lib/msfl_visitors/visitor.rb
Instance Method Summary collapse
- #composable_expr_for(regex_as_literal_string) ⇒ Object
-
#escape_es_special_regex_chars(str) ⇒ Object
Note that the ES documentation also indicates that # is a special character that requires escaping and that this behavior is not part of the PERL regex; however Ruby automatically escapes literal hashes when constructing regices.
- #escaped_regex_helper(escaped_str) ⇒ Object
Instance Method Details
#composable_expr_for(regex_as_literal_string) ⇒ Object
18 19 20 |
# File 'lib/msfl_visitors/visitor.rb', line 18 def composable_expr_for(regex_as_literal_string) regex_as_literal_string[3..-4] end |
#escape_es_special_regex_chars(str) ⇒ Object
Note that the ES documentation also indicates that # is a special character that requires escaping and that this behavior is not part of the PERL regex; however Ruby automatically escapes literal hashes when constructing regices
8 9 10 |
# File 'lib/msfl_visitors/visitor.rb', line 8 def escape_es_special_regex_chars(str) str.gsub(/([@&<>~])/) { |m| "\\#{m}" } end |
#escaped_regex_helper(escaped_str) ⇒ Object
12 13 14 15 16 |
# File 'lib/msfl_visitors/visitor.rb', line 12 def escaped_regex_helper(escaped_str) exp = escape_es_special_regex_chars "#{escaped_str}" # why you must use #inspect, not #to_s. @link http://ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-7E %r[.*#{exp}.*] end |