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:

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
  • 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 while o:/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.

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.

\sm

Short-hand for any mana symbol

\sc

Short-hand for any colored mana symbol

\ss

Short-hand for any card symbol

\smr

Short-hand for any repeated mana symbol. For example, {G}{G} matches \smr

\smh

Short-hand for any hybrid card symbol. Note that monocolor Phyrexian symbols aren’t considered hybrid.

\smp

Short-hand for any Phyrexian card symbol, e.g. {P}, {W/P}, or {G/W/P}.

\spt

Short-hand for a X/X power/toughness expression

\spp

Short-hand for a +X/+X power/toughness expression

\smm

Short-hand for a -X/-X power/toughness expression

Atoms

The following atoms are supported:

Atom Description

.

Any single character except \n

[kf]

Bracket expression matching a single character which is k or f (or any other group of literal characters)

[^kf]

Bracket expression matching a single character which is not k or f (or any other group of literal characters)

[f-k]

Bracket expression matching a single character which is between f through k in Unicode, inclusive (or any other range of of literal characters)

(re)

A group that matches the expression re

(re|fe)

A group that matches either the expression re or fe. | is the pipe character.

\k

A literal escaped k (or any other character)

k

The character k (or another non-meta 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

{M}

A sequence of exactly M matches of the atom, where M is a number

{M,}

A sequence of M or more matches of the atom

{M,N}

A sequence of M through N (inclusive) matches of the atom; M cannot exceed N

*?

Non-greedy version of *

+?

Non-greedy version of +

??

Non-greedy version of ?

{M}?

Non-greedy version of {M}

{M,}?

Non-greedy version of {M,}

{M,N}?

Non-greedy version of {M,N}

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

\b

Matches the boundary of a word

(?=re)

Positive lookahead: matches at any point where a substring matching re begins

(?!re)

Negative lookahead: matches at any point where no substring matching re begins

(?<=re)

Positive lookbehind: matches at any point where a substring matching re ends

(?<!re)

Negative lookbehind: matches at any point where no substring matching re ends

Character Classes

The following character classes are supported:

Class Description

\n

Matches a newline

\s

Matches any whitespace

\d

Matches a single digit character: 0–9

\w

Matches any word character: A through z and 0 through 9

\uHHHH

Matches a character whose hexadecimal value is HHHH, where HHHH is exactly four hexadecimal digits