[RUBY] colorize and regular expressions

ruby-2.7.1p83

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.

Regular expression

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

colorize and regular expressions
Regular expressions
Switch beans with @ConditionalOnExpression and SpEL regular expressions
Notes on regular expressions
Distinguish between integers and decimals with regular expressions
[Ruby] Exclude and replace specific patterns with regular expressions
[RSpec] WebMock handles regular expressions and Array query strings
[Java] Summary of regular expressions
About regular expressions in Ruby
Learn regular expressions little by little ①
[Java] Comparison method of character strings and comparison method using regular expressions
Handling of line beginning and line ending in regular expressions in Ruby
About C # lambda expressions and Linq
Rails: Capture regular expressions in emails!
I want to be able to think and write regular expressions myself. ..
Java for beginners, expressions and operators 1
Java for beginners, expressions and operators 2
Parse Japanese addresses with regular expressions
Name a group of regular expressions (Java)
Easily make troublesome regular expressions with Rubular
Nowadays Java lambda expressions and Stream API
Regular expressions that match 99% of email addresses
Easy to trip with Java regular expressions