Sha256: 4e898bcc7f35bfc3ad2bfd15500002056b8115edb87d1b05d6c809559db21297

Contents?: true

Size: 427 Bytes

Versions: 3

Compression:

Stored size: 427 Bytes

Contents

class String

  # Escape string for Regexp use.
  #
  #   "H..LO".regesc  #=> "H\\.\\.LO"
  #
  #   CREDIT: Trans

  def regesc
    Regexp.escape(self)
  end

end


module Kernel

  # Provides a shortcut to the Regexp.escape module method.
  #
  #   resc("H..LO")   #=> "H\\.\\.LO"
  #
  #   TODO: Should this be deprecated in favor of String#regesc ?
  #
  #   CREDIT: Trans

  def resc(str)
    Regexp.escape(str)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.3.0 lib/core/facets/string/regesc.rb
facets-2.2.0 lib/core/facets/string/regesc.rb
facets-2.2.1 lib/core/facets/string/regesc.rb