Docs

RunMacro Documentation

Create your first robot, then go further as needed.

Clear step-by-step guides to create, run, and improve robots for repetitive computer work.

Docs Variables Extract Regex
🔎 Variables

Extract data with Regex into a variable in RunMacro

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.

Prerequisites#

  • Add Extract Regex to the macro.
  • Prepare the data or target that Extract Regex will use.

Supported modes#

  • 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

What it does#

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.

Screenshots & video#

RunMacro Extract Regex command configuration dialog showing parameter fields
Configuration dialog and parameter fields for the Extract Regex command in RunMacro.

When to use it#

  • 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.

When not to use it#

  • Do not use it for structured JSON/CSV/HTML or an untested regex.

Configuration steps#

  1. Add a Variables › Extract Regex command.
  2. Choose the source (Variable / Text / Clipboard) and enter the source value.
  3. Enter the regex pattern (e.g. \d{6} for 6 digits) and the result variable.
  4. (Optional) choose the group/match index. Save.

Every option explained#

Source + source value#

Where to read the text: a variable, typed text, or the clipboard.

Regex pattern#

The regular expression to match. Examples: \d{6}, [\w.]+@[\w.]+.

Group + match index#

Group 0 = whole match; a number/name gets a captured group. Match index selects which match when several exist.

On no match#

Choose to continue with an empty value, or treat it as a failure.

Extract-all mode (mode = all)#

Instead of one result, capture every match into numbered variables var_1, var_2... plus a count variable (var_count). You can set an expected count to flag mismatches, and hide the values in the log.

Expected result#

After execution, Extract Regex completes the described action and makes its result available to the next step.

Real example#

Example: extract a 6-digit OTP from the clipboard#

  1. Copy the message containing the OTP.
  2. Extract Regex: source Clipboard, pattern \d{6} → variable otp.
  3. Use {otp} to fill the code field.

Limitations and failure cases#

  • An invalid pattern, group, or match index yields no result; Extract All creates numbered and count variables.

Tips & common mistakes#

Test the pattern on an online regex tool first to be sure it matches the right part.

Verification details#

  • commands/variables.py
RunMacro robot

Robots do the work. Your time is yours.

Create a robot in minutes, no coding needed. Reliable execution, remote management, transparent costs — and you always stay in control.