Extract data with Regex into a variable in RunMacro
Desktop ModeBrowser ModeRunMacro RunnerRunMacro 3.5+
The Extract Regex command uses a regular expression to pull a piece of data (OTP, email, number...) from a variable, text, or the clipboard, then stores it in a variable.
Dialog & quick setup

- Add a Variables › Extract Regex command.
- Choose the source (Variable / Text / Clipboard) and enter the source value.
- Enter the regex pattern (e.g.
\d{6}for 6 digits) and the result variable. - (Optional) choose the group/match index. Save.
Options reference
Modes & when to use
Desktop Mode
Browser Mode
Runs in the background through Chrome CDP: when the source is the clipboard, the command reads RunMacro’s virtual clipboard instead of the system clipboard.
RunMacro Runner
Best for
- Grab a 6-digit OTP from a message/email.
- Pull an email or phone number from a block of text.
- Isolate the needed data before using it.
Use an alternative when
- Do not use it for structured JSON/CSV/HTML or an untested regex.
Before you run
- Add Extract Regex to the macro.
- Prepare the data or target that Extract Regex will use.
Example workflow
Example: extract a 6-digit OTP from the clipboard
- Copy the message containing the OTP.
- Extract Regex: source Clipboard, pattern
\d{6}→ variableotp. - Use
{otp}to fill the code field.
Expected result: After execution, Extract Regex completes the described action and makes its result available to the next step.
Tips & limitations
Test the pattern on an online regex tool first to be sure it matches the right part.
- An invalid pattern, group, or match index yields no result; Extract All creates numbered and count variables.
Applies to RunMacro 3.5+ · Desktop Mode & Browser Mode & RunMacro Runner · Windows 10/11
