colorize
You can use colorize to color the characters output by the terminal.
For example
require 'colorize'
def assert_equal(expected, result)
if expected == result
puts 'true'.cyan
else
puts 'false'.magenta
end
end
assert_equal(1, 1)
Then, true is displayed in cyan and false is displayed in magenta.
Rubular (http://rubular.com) is a Ruby-based regular expression editor. You can try it as a test when writing a regular expression.
For example, as test string
Hello world!
In the regular expression part
\s(.+)
If you enter
world!
Only can be extracted.
I found it convenient to be able to check before actually writing in the program.
Recommended Posts