Lifted directly from sed, one of Perl's inspirations:
s/replace #/with $/
s#replace /#with _# s/replace #/with $/
s#replace /#with _# irb(main):001:1/ puts(%r
irb(main):002:1* a+
irb(main):003:0> .match? %q aaa )
true