Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby remove backslash from string

Tags:

ruby

How would I make this a regular string with no slash?

I have:

 "3e265629c7ff56a3a88505062dd526bd\""

I want:

"3e265629c7ff56a3a88505062dd526bd"
like image 247
BC00 Avatar asked Nov 29 '22 12:11

BC00


1 Answers

What you have:

"3e265629c7ff56a3a88505062dd526bd\""

Is equivalent to:

'3e265629c7ff56a3a88505062dd526bd"'

So to remove that:

string.tr!('"', '')

Remember all special characters are prefixed with backslash. This includes not only things like newline \n or linefeed \r, but also quotation mark " or backslash itself \\.

like image 140
tadman Avatar answered Dec 24 '22 16:12

tadman