The page supports testing
String replace and
The results are shown in easy to understand tables showing all matches and all groups.
Enter regular expression in code format (like you would in code).
Syntax errors will be reported as you type. When errors have been fixed a RegExp construtor will be shown, ready to copy/paste.
The syntax you use depends on the constructor format, you have chosen (the tabs).
You can choose between literal verbatim RegExp constructor and string constructors, using either doublequotes or singlequotes. Switching between them will convert the regular expression to that format.
RegExp constructor format:
Literal verbatim constructor (@/ /): Here you don't need to double escape control characters, example '\n' matches a newline.
Slashes (/) must be escaped, example '\/' matches one slash.
Literal double quoted string (" "): Here you need to double escape all control characters, example '\\n' matches a newline.
Doublequotes must be escaped, example '\\"' matches one doublequote.
Literal single quoted string (' '): Here you need to double escape all control characters, example '\\n' matches a newline.
Singlequotes must be escaped, example '\\"' matches one doublequote.
The 'RegExp constructor' will show the RegExp constructor based on your RegExp and options, ready to copy and paste into your code.
Switching to the other constructor types (by clicking the tabs) will also change the constructor to that format.
Which method to use in your code:
String match is the universal way, if you only want one match (without the 'global' flag). That will give you access to groups.
With global flag set, it only returns matches, no information about groups.
String matchAll is the newer way to multi-match. It must have the global flag set. Then it returns all matches, including info on all groups.
String replace will only replace the first match, when global flag is not set. With global flag set, it replaces all matches.
String replaceAll must have the global flag set and it replaces all matches (like 'String replace' will global flag set).