I have e.g. r = "\t"
and a = "thisisabigbad\wolf"
How can I prevent ruby from auto escaping my string and also count the \
at the same time?
a.count r #=> this should return 2 instead of 0
I wish to do a.count
and receive 2
I have e.g. r = "\t"
and a = "thisisabigbad\wolf"
How can I prevent ruby from auto escaping my string and also count the \
at the same time?
a.count r #=> this should return 2 instead of 0
I wish to do a.count
and receive 2
You can use single quotes:
[17] pry(main)> r = '\t'
=> "\\t"
[18] pry(main)> r.size
=> 2
[20] pry(main)> a = 'thisisabigbad\wolf'
=> "thisisabigbad\\wolf"
[21] pry(main)> a.size
=> 18