Sha256: 0e6db19cdf41c444b5b761dee6e719dd62f76e8c291f26dc0c64ae059d279d9d
Contents?: true
Size: 640 Bytes
Versions: 1
Compression:
Stored size: 640 Bytes
Contents
class String # Turns a string into a regular expression. # By default it will escape all characters. # Use <tt>false</tt> argument to turn off escaping. # # "[".to_re #=> /\[/ # def to_re(esc=true) Regexp.new((esc ? Regexp.escape(self) : self)) end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCString < Test::Unit::TestCase def test_to_re assert_equal( /abc/, "abc".to_re ) assert_equal( /a\+bc/, "a+bc".to_re ) assert_equal( /a+bc/, "a+bc".to_re(false) ) end end =end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-0.9.0 | lib/nano/string/to_re.rb |