This is an explanation of what your 2 examples do. Whilst it isn't really an answer it's a bit long to fit in a comment.
=~ returns the position where a match occurs or nil if no match is found.
In your first example 'http://ale.it' matches URI::regexp starting at position 0 so you get 0.nil? which is false, converted to a string "false"
gsub in your second example takes 2 parameters, a pattern and a replacement string and replaces all matches of the pattern with the replacement.
'\0' doesn't match URI::regexp so ('\0' =~ URI::regexp).nil? is true and with to_s applied is the string "true".
"http://ale.it" matches /http[s]?:\/\/[^\s]+/ so gets replaced with "true".
You will have to expand your question to explain what you're trying to achieve.