Regular Expressions
You can use forward slashes //
instead of quotes
with the
type://
, t://
oracle://
, o://
,
flavor://
, ft://
,
and name://
keywords
to match those parts of a card
using regular expressions.
Regular expressions are very powerful, here are some examples of fancy searches you can make with regular expressions:
- Instants that grant +X/+X boosts
- Creatures that have a tap ability with no other payment
- Cards that mention orcs, but not other words like sORCery or ORChard
- The Thingling cycle
Scryfall Regex Flavor
Scryfall supports most POSIX regular expression constructs, many are detailed below. Our regular expressions have the following configuration and limits:
- All regular expressions are case-insensitive
- All regular expressions are newline-sensitive (also known as “multiline” mode)
- The
.
character will not match\n
, you must explictly opt-in to matching newlines with an expression like(.|\n)
or similar - The line anchors
^
and$
will match the start and end of paragraphs in Oracle text, instead of the start and end of the entire field
- The
- All characters in your expression are significant and whitespace will be matched (also known as “tight mode”)
- If your expression includes forward slashes
/
they must be escaped:\/
- Scryfall regular expressions are Unicode-aware. The
.
will match characters beyond the ASCII range. - Backreferences are not supported (
\1
,\2
, etc) - You cannot add your own configuration to regular expressions on Scryfall.
For example
o:/tap/
will work whileo:/tap/gi
will not. - Scryfall regular expressions are match-only. Scryfall does not support extracting data from capture groups or performing substitutions.
- Scryfall uses only the
\n
character for newlines in all text fields across our entire database. No fields include\r
or\f
. - The Scryfall database does not include bells (
\a
), null-bytes (\0
), or other esoteric control characters.
Please also note: Due to implementation details, attempting to count the total number of words or lines in a particular text field may not be accurate.
Scryfall Extensions
Scryfall includes the following additional, non-standard regex features. Please note that none of the expressions in the table below are formal character classes, it is just shorthand we have added.
Syntax | Feature |
---|---|
|
An automatic alias for the current card name or “this spell” if the card mentions itself. |
|
Short-hand for any mana symbol |
|
Short-hand for any colored mana symbol |
|
Short-hand for any card symbol |
|
Short-hand for any repeated mana symbol. For example, |
|
Short-hand for any hybrid card symbol. Note that monocolor Phyrexian symbols aren’t considered hybrid. |
|
Short-hand for any Phyrexian card symbol, e.g. {P}, {W/P}, or {G/W/P}. |
|
Short-hand for a X/X power/toughness expression |
|
Short-hand for a +X/+X power/toughness expression |
|
Short-hand for a -X/-X power/toughness expression |
Atoms
The following atoms are supported:
Atom | Description |
---|---|
|
Any single character except |
|
Bracket expression matching a single character which is |
|
Bracket expression matching a single character which is not |
|
Bracket expression matching a single character which is between |
|
A group that matches the expression |
|
A group that matches either the expression |
|
A literal escaped |
|
The character |
Quantifiers
The following quantifiers are supported:
Quantifier | Description |
---|---|
|
A sequence of 0 or more matches of the atom |
|
A sequence of 1 or more matches of the atom |
|
A sequence of 0 or 1 matches of the atom |
|
A sequence of exactly |
|
A sequence of |
|
A sequence of |
|
Non-greedy version of |
|
Non-greedy version of |
|
Non-greedy version of |
|
Non-greedy version of |
|
Non-greedy version of |
|
Non-greedy version of |
Anchors and Lookarounds
The following anchors/lookarounds are supported:
Anchor | Description |
---|---|
|
Matches at the beginning of a line or the beginning of the field |
|
Matches at the end of a line or the end of the field |
|
Matches the boundary of a word |
|
Positive lookahead: matches at any point where a substring matching |
|
Negative lookahead: matches at any point where no substring matching |
|
Positive lookbehind: matches at any point where a substring matching |
|
Negative lookbehind: matches at any point where no substring matching |
Character Classes
The following character classes are supported:
Class | Description |
---|---|
|
Matches a newline |
|
Matches any whitespace |
|
Matches a single digit character: |
|
Matches any word character: |
|
Matches a character whose hexadecimal value is |