Example:
String test="hi\000\000\000"
Problem: Some methods require a string to be without nulls, how can I delete all null values of a string?
.split("\000",1) gives me an error: 'force_encoding' method doesn't exist
.gsub('\000','') does nothing
Even more simple:
test.delete("\000")
Try using double quotes, so test.gsub("\000", '')
.
Right now I tried this in JRuby and it worked:
test.gsub(/\000/, '')
Note that I am using a regex in the gsub and not a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With