Rate this script:  I Love it  /   I Hate it

Escape a character with backslashes


Code


s = "12345"
puts s.gsub(/(2|4)/, '\\\\\1')

$s="12345";
print preg_replace("/(2|4)/", '\\\\\1', $s);

$s="123456";
$s =~ s/(2|4)/\\\1x/g;
print $s;
 

 

 
Escape a character with backslashes scripts | Escape a character with backslashes snippet | Escape a character with backslashes example | Escape a character with backslashes tutorial | Escape a character with backslashes code