Explore regular expressions as finite automata, with extra operators for wordplay (see the full syntax below).
Loading…
Test strings
One per line: matches or doesn't. For the line with the cursor, the panel beside it shows which part of the pattern matched each character, and the diagram highlights the states reached by the text before the cursor.
Word list
Load a text file with one word or phrase per line, or a ready-made list, to see which words the pattern matches. Click a match to add it to the test strings and see how it matches. The @ list specifies what @ stands for in a pattern. Both lists are kept in this browser.
Patterns match whole strings, so there are no anchors: unlike in most regex dialects, ^ means interleaving (see below), not the start of the string. All ASCII punctuation except ' is reserved, so write \., \-, \\ and so on to match it literally.
| Characters | |
|---|---|
a \* \n \u{e9} | a character |
. _ | any character; an ASCII letter, the same as [a-zA-Z] |
[abc] [a-z] [^a-z] | character classes ([] matches nothing) |
\d \w \s | an ASCII digit; an ASCII letter or digit, or _; ASCII whitespace. \D, \W and \S are the opposites, and all of these work inside classes too, as in [\d_] |
\p{L} \P{L} | a character with or without a Unicode property, as in JavaScript (\p{Lu} is an uppercase letter, \p{Script=Greek} a Greek character) |
@ | any word in the @ list, or in the word list if no @ list is loaded |
\Q...\E | the characters in between, taken literally (\Qe.g.\E matches e.g.) |
| Repetition and sequence | |
P* P+ P? | 0 or more; 1 or more; 0 or 1 |
P{n} P{n,} P{m,n} P{,n} | n; n or more; m to n; up to n |
PQ | P followed by Q |
| Combining strings | |
P<Q P>Q | P inside Q; P outside Q (o+<l+ matches loool) |
P<<Q P>>Q | strictly inside or outside, with the outer part on both sides |
P^Q | P interleaved with Q (the^A+ matches tAAhAe) |
P<^Q P>^Q | interleaved strictly inside or outside, with the outer part at both ends |
P#Q P##Q | P alternating with Q, in either order; with P first (U+##w+ matches UwUwU) |
P-Q P~-Q | P with Q removed from the end or the start ((the|a)-. matches th) |
P-opQ | P with Q removed according to any operator above: -< -> -<< ->> -^ -<^ ->^ -# -## ~-## (Madrid-^.. matches Mdrd) |
(?w:S/P/Q) (?u:S/P/Q) | P and Q combined by a custom split S, a pattern over L (for P's characters) and R (for Q's), as in the operators above; P with Q removed by S ((?w:L+R+L+/the/[a-z]+) matches tithe) |
| Logic | |
!P | anything P doesn't match |
P&Q | both P and Q |
P|Q | either P or Q |
(P) | grouping |
| Lookarounds (unlike in PCRE, these only see their own group or operand, so can't look outside it) | |
(?=P) (?!P) | what follows starts with P; doesn't ((?!the)[a-z]+ matches tea but not then) |
(?<=P) (?<!P) | what precedes ends with P; doesn't ([a-z]+(?<!ing) matches sang but not sing) |
\b \B | a word boundary (\w on one side only); not one (.*\bcat.* matches a cat but not concat) |
| Names | |
(?<v>P) (?&v) | P, named v; P again (the same pattern, not the same text). (?<v>P){0} names P without matching it ((?<c>[^aeiou])[aeiou](?&c) matches cat) |
| Modifiers and transformations | |
(?i:P) (?d:P) | P ignoring case; ignoring accents ((?i:the) matches THE, (?d:cafe) matches café); the Ignore tickboxes do these for the whole pattern |
(?cn:P) (?c:P) (?c-:P) | P with its letters shifted n places along the alphabet; by any of 1 to 25; in Atbash, with the alphabet reversed ((?c1:hal) matches ibm, (?c-:hold) matches slow) |
(?r:P) | P reversed ((?r:stop) matches pots) |
(?Rn:P) (?R:P) | P rotated n characters right (left if n is negative); by any amount ((?R:cat) matches atc and tca) |
(?tn:P) (?t:P) | P with two characters n apart swapped ((?t1:the) matches teh and hte); any two |
(?a:P) | anagrams of P, which must have finitely many strings, since anagrams of infinite ones may not be regular ((?a:listen) matches silent). (?a:P-^.*) gives sub-anagrams |
(?X:P) | P with non-letters added anywhere, for crossword answers; the same as P^\P{L}* ((?X:a__t) matches abet and a lot) |
(?[m:n]:P) (?[m:n:s]:P) | P sliced as in Python: characters m up to but not including n, counting from 0 (from the end if negative); every s-th one. Too-short strings are skipped ((?[1:-1]:spam) matches pa) |
(?z:P/Q/R) (?Z:P/Q/R) | P with a Q replaced by an R; but not at either end ((?z:London/o/u) matches Lundon). To replace at the end or start, write (P-Q)R or R(P~-Q) |
Operators like *, < and & are listed from tightest to loosest binding, so !ab<c|d means (!((ab)<c))|d. One of the operators from < to -op can be repeated, as in a-b-c, but different ones need parentheses, as in (a<b)^c.