Something in my computer-science-student background feels unsettled when I can use a language for years and still learn new tricks (or often, that I've forgotten that I've learned) about common functionality such as string interpolation...but I do love a lot of Ruby's tricks.<p><pre><code> if path =~ %r{^/assets/mobile/img}
...
end
</code></pre>
I knew about `%r` but hadn't realized that it escapes forward-slashes while leaving other regex symbols intact. But with the previous explanation of `%q`, in which arbitrary delimiters can be used, it makes sense...curly braces simply replace `/` as the delimiter, and `/` simply retains its non-specialness in regex...saves me a lot of writing `Regex.escape("/path/to")`.<p>Another regex notation that I recently learned (elsewhere) and now love to abuse:<p><pre><code> "He is 32-years old"[/\d+/] # => "32"
</code></pre>
as opposed to:<p><pre><code> "He is 32-years old".match(/\d+/)[0]</code></pre>