[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

You can try and use regular expressions! Introducing RegExr

Hello.
I'm Mandai, in charge of Wild on the development team.

Regular expressions are often used during development, and if you write random regular expressions, there is a possibility that you may end up with a shocking bug.
So, if you want to test regular expressions or check their operation, but don't want to write test code, I'd like to introduce you to some useful sites.

 

Let's use RegExr to check regular expressions

There is a site called RegExr

This site has a lot of useful functions for checking regular expressions, and I think it's easy to use.

Originally, it was a site where you could check only JavaScript regular expressions, but recently, while I wasn't looking, it also supported PHP regular expressions (PCRE).

It's easy to use, and there are some parts that you can understand just by looking at them, but since the entire site is in English, I'd like to go through them one by one.

 

The menu includes site help and regular expression cheat sheets.

In particular, you'll be looking at cheat sheets and references often, so it's a good idea to memorize them.

It is useful because it is designed to be easy to read.

 

Expression

From here, we will write the actual regular expression in the Expression section, which is a frequently used item.

Since it is basically JavaScript, you will need to write the regular expression between "/" and the part enclosed by "/".

The parts surrounded by "()" and "[]" are color-coded, making it very easy to understand visually.
I would like this kind of functionality to be added to VSCode as well...

On the right side of the title, you can select either JavaScript or PCRE as the regular expression execution engine.
You can also choose from 5 options under Flags.

  • g (global)
  • i (case insensitive)
  • m (multiline)
  • u (unicode)
  • y (sticky)
This is an option that PHP does not have.

Each option can be set using JavaScript, so for example in PHP, there is no global flag, so you will need to select a dedicated function called preg_match_all.

 

Text

Enter sample text in this field.
Various things are written by default, but you can delete them or enter them yourself.

Matches are shown with a blue background

Enter any suspicious strings or strings you want to test.

 

Tools

This item contains a set of tools for cooking the results of regular expressions, and the following four are currently available.

 

Replace

A tool for replacing strings matched by regular expressions.
This tool allows you to perform simple string transformations, so it can be used as more than just a regular expression checking tool.

It works well even in Japanese

 

List

List displays a list of strings matched by a regular expression.

The matched string will be placed in the part displayed by "$&", so you can add the string you want to add all at once by entering the string you want to add before and after the extracted string.

By default, "\n" is added, so each matched string is added to a new line, but if you add "-" to the beginning of the string, you can make the matched strings into a markdown list. It's also easy to do.
This is convenient.

 

Details

The tool Details allows you to know in detail which part of the regular expression the selected string matches.
It's possible that you're only getting the expected result because you matched in a part that wasn't what you expected, so check here to make sure the process is working correctly.

Click on the matching part of the TEXT item to display that information.

 

Explain

This is a feature similar to MySQL's EXPLAIN. You can see which strings are grouped by parentheses, and which parts of the strings are matched by the parentheses.
This is also very useful.

 

summary

We introduced the functions of RegExr, a regular expression checking tool, but what did you think?
With recent updates, it has become more and more convenient, with support for PHP and the addition of tools that allow you to do more than just check regular expressions.

Personally, I often use Excel to use the Replace and List tools, so I thought I'd try working a little more intelligently.

 
That's it.

If you found this article helpful , please give it a like!
1
Loading...
1 vote, average: 1.00 / 11
1,750
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also fortunate to be able to do a lot of other work, including marketing.
Furthermore, my portrait rights in Beyond are treated as CC0 by him.