IUPAC to Regex Converter
Turn a degenerate nucleotide motif written with IUPAC ambiguity codes into a regular expression. Paste the result into any regex-capable tool to search a DNA sequence for the motif.
Enter an IUPAC nucleotide motif to get its regex.
How it works
IUPAC ambiguity codes let a single letter stand for several possible bases: N is any base, R is A or G, Y is C or T, W is A or T, S is G or C, and so on. To search a sequence for a degenerate motif, each code is expanded into a regular-expression character class — for example N becomes [ACGT] and R becomes [AG] — while unambiguous bases stay as themselves.
Enter a motif and the converter builds the equivalent regular expression. Paste it into a programming language, a text editor, or a genome browser's regex search to find every match of the motif, including all the ambiguous possibilities.
Examples
- GGNCC → GG[ACGT]CC (matches GGACC, GGCCC, GGGCC, GGTCC).
- GAATTC → GAATTC (the EcoRI site, no ambiguity).
- WS → [AT][GC].
Frequently asked questions
- What are IUPAC ambiguity codes?
- They are single-letter codes that represent a set of nucleotides, such as R for purines (A/G), Y for pyrimidines (C/T) and N for any base. They are used to describe degenerate primers and motifs.
- How is the regex built?
- Each code is replaced by a character class of the bases it represents — N becomes [ACGT], R becomes [AG] — and plain bases are left unchanged, producing a pattern that matches every possible sequence of the motif.
- Where can I use the regex?
- Anywhere regular expressions are supported: a programming language, a code editor's search, command-line tools like grep, or a sequence search box that accepts regex.
- Is it case sensitive?
- The converter uppercases the motif, so the resulting pattern matches uppercase sequence. Add a case-insensitive flag in your regex engine if you need to match lowercase bases too.