Kev Jackson wrote: > Hi all, > > I need to escape / in a gsub! > > eg > > line = line.gsub!(///, '') > > Unfortunately I don't know how to escape the / (forward slash) - the > data I'm munging has this in it (annoyingly) > > Kev If you use this method, you don't need to escape the slashes: "09/30/05".sub( %r{(\d\d)/(\d\d)/(\d\d)}, '\3-\1-\2') "09/30/05".sub( %r!(\d\d)/(\d\d)/(\d\d)!, '\3-\1-\2') "09/30/05".sub( %r](\d\d)/(\d\d)/(\d\d)], '\3-\1-\2')