Regex Tester

Assistai DEV Tools

//gm

Code Generator

JavaScript//m // Use with .match() or .matchAll() for global
Pythonimport re pattern = re.compile(r'' | re.MULTILINE) result = re.findall(pattern, text)
Goimport "regexp" re := regexp.MustCompile(`(?m)`) result := re.FindAllString(text, -1)
PHP$$pattern = '//m'; $$result = preg_match_all($$pattern, $$text, $$matches);
Rustuse regex::Regex; let re = Regex::new(r"(?m)").unwrap(); let result = re.find_iter(text);

Cheatsheet

Character Classes

.Any char except newline
\dDigit (0–9)
\DNon-digit
\wWord (a-z, A-Z, 0-9, _)
\WNon-word
\sWhitespace
\SNon-whitespace

Quantifiers

*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m

Anchors & Groups

^Start of string
$End of string
\bWord boundary
( )Capturing group
(?: )Non-capturing group
|Alternation (OR)

Lookaround

(?= )Positive lookahead
(?! )Negative lookahead
[abc]Character class
[^abc]Negated class
[a-z]Range