Clipboard matches
Passes when the clipboard text matches a regular expression.
The clipboard matches regex
Keyboard Maestro: Text (clipboard matches)
Details #
Reads the text on the clipboard and searches it for regex. The match can be anywhere in the text; anchor with ^ and $ to match the whole thing. Matching is case sensitive. A clipboard with no text counts as empty text.
Every condition accepts "negate": true, which flips the verdict. The trace records what was compared before the flip, so a negated condition that blocks a macro still shows the real values.
Conditions in an Only if list combine with all: every one must pass, and an empty list always passes. An if step or a repeat loop takes a match of all (default) or any.
The trace shows clipboard (the first 200 characters) and regex.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
regex | text | Yes | A regular expression. Escape backslashes in JSON: \\d+ for digits. |
Examples #
- Press ⌃⌥J
- If the clipboard matches “^https?://”
- Show “Clipboard holds a link”
- Press ⌃⌥J
- If the clipboard doesn't match “\d”
- Show “No digits copied”
Gotchas #
An invalid regular expression makes the condition error rather than fail.