Sha256: ed04e98f33d551e16834712b569b5aafca82b7d64d5410e0daeb1e53b52d5bfa
Contents?: true
Size: 479 Bytes
Versions: 20
Compression:
Stored size: 479 Bytes
Contents
class String # Turns a string into a regular expression. # # "a?".to_re #=> /a?/ # # CREDIT: Trans def to_re(esc=false) Regexp.new((esc ? Regexp.escape(self) : self)) end # Turns a string into a regular expression. # By default it will escape all characters. # Use <tt>false</tt> argument to turn off escaping. # # "[".to_rx #=> /\[/ # # CREDIT: Trans def to_rx(esc=true) Regexp.new((esc ? Regexp.escape(self) : self)) end end
Version data entries
20 entries across 19 versions & 2 rubygems