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.
Chart type ruby-appendix-V (rubular)
Recommended Posts