Mega Code Archive

 
Categories / Ruby / Development
 

Backslash Sequences in the Substitution

"fred:smith".sub(/(\w+):(\w+)/, '\2, \1') # "smith, fred"  "nercpyitno".gsub(/(.)(.)/, '\2\1') # "encryption"