/ / Ruby: can I avoid lots of escaping in a regex? [duplicate] - ruby, regex, escaping

रुबी: क्या मैं रेगेक्स में भागने से बच सकता हूं? [डुप्लिकेट] - रूबी, रेगेक्स, भागना

Lets say I want to match against CVS comments like:

//     $Source$

My regex currently looks like this:

if ( /^//s*$Source$/ =~ line)

Which works, but I"m left wondering -- is there a prettier way to write this?

उत्तर:

जवाब के लिए 0 № 1

उपयोग %r वाक्य - विन्यास:

if ( %r{//s*$Source$} =~ line)
^^ I"m not sure whether ruby would allow unescaped `$` here or not