[RUBY] Easily make troublesome regular expressions with Rubular

!macOS-11.1!ruby-2.7.2p137

Preface (Introduction)

Regular expressions are useful for extracting the string you want. However, regular expressions are often memorized and take a lot of time to master.

Therefore, a tool called Rubular that does regular expressions in Ruby is useful.

rubular

The Your regular expressio above is where you put your regular expression.

The Your test string on the left is the string, and the extraction result is on the right.

The Regex quick reference below shows some examples of regular expressions.

Example

First, the test string

#+qiita_id: helloworld

In Your test string.

Now, let's take out helloworld from here. To Your regular expression

(.+)

This is . for any single character and+for one or more, Enclose in (...) to represent capture everything enclosed.

#+qiita_id: helloworld
1. #+qiita_id: helloworld

To retrieve only hello world

:(.+)

You can.

Regular expressions are hard to remember, so I'll continue to learn using rubular.

Reference material

Chart type ruby-appendix-V (rubular)

Recommended Posts

Easily make troublesome regular expressions with Rubular
Parse Japanese addresses with regular expressions
Make a site template easily with Rails
Easy to trip with Java regular expressions
Distinguish between integers and decimals with regular expressions
[Ruby] Exclude and replace specific patterns with regular expressions
Notes on regular expressions
colorize and regular expressions