Go Regex Tester ( RE2 )
Pattern: e.g. (?P<key>\w+)=(?P<value>\w+) , \d{1,3}(\.\d{1,3}){3} , (?imsU)^hello.*world$
Test Text:
Go's standard library regular expressions are implemented based on the RE2 engine, providing safe and efficient pattern matching capabilities. It supports standard regular expression syntax but does not support backtracking, ensuring stable and predictable performance.
Single-character Expression TypeExample
Any character (including newline if s=true).
Character class[xyz]
Negated character class[^xyz]
Perl character class\d
Negated Perl character class\D
ASCII character class[[:alpha:]]
Negated ASCII character class[[:^alpha:]]
Unicode character class (single letter)\pN
Unicode character class\p{Greek}
Negated Unicode character class\PN
Negated Unicode character class\P{Greek}
Composite ExpressionsMeaning
xyx followed by y
x|yx or y (prefer x)
Grouping ExpressionsDescription
(re)Capturing group
(?P<name>re)Named capturing group
(?:re)Non-capturing group
Escape SequencesDescription
\nNewline
\tTab
\x7FHex character
\Q...\ELiteral text
Repetition ExpressionsMeaning
x*0 or more x (greedy)
x*?0 or more x (lazy)
x+1 or more x (greedy)
x+?1 or more x (lazy)
x?0 or 1 x (prefer 1)
x??0 or 1 x (prefer 0)
x{n,m}n to m x (greedy)
x{n,}at least n x
x{n}exactly n x

Note: The maximum limit for counting forms like x{n,m} is 1000.

FlagsDescription
iCase-insensitive (default: false).
e.g. (?i)hello matches "hello" and "Hello".
mMulti-line mode: ^ and $ match the start and end of each line as well as the whole text (default: false)
e.g. (?m)^b.* matches “banana” in "apple\nbanana\ncherry".
sAllows . to match newline \n (default: false).
e.g. (?s)start(.*)end matches "start B \n new line \n end"
UUngreedy mode switch: swaps meanings of x* and x*?, x+ and x+?, etc. (default: false)
Reversal: x* becomes lazy, x*? becomes greedy, x+ becomes lazy, x+? becomes greedy.
e.g. text:="a123b456b" comparison:
  • (?U)a.*b → “a123b” (lazy, stops at first b)
  • a.*b → “a123b456b” (greedy, matches as much as possible)
Anchors (Zero-width)Description
^Start of text or line
$End of text or line
\AStart of text
\bWord boundary (one side is \w and the other is \W or start/end)
\zEnd of text (end of entire string, e.g. world\z matches "hello\nworld")
Perl Character ClassMeaning (ASCII only)
\dDigit (equivalent to [0-9])
\DNon-digit (equivalent to [^0-9])
\sWhitespace (equivalent to [\t\n\f\r ])
\SNon-whitespace (equivalent to [^\t\n\f\r ])
\wWord character (equivalent to [0-9A-Za-z_])
\WNon-word character (equivalent to [^0-9A-Za-z_])

Note: \h, \H, \v, \V are not supported.

Named Character Classes as Elements
[\d]Digit (≡ \d)
[^\d]Non-digit (≡ \D)
[\D]Non-digit (≡ \D)
[^\D]Not non-digit (≡ \d)
[[:name:]]Named ASCII class inside character class
[^[:name:]]Negated named ASCII class
[\p{Name}]Named Unicode property inside class
[^\p{Name}]Negated Unicode property
ASCII Character ClassesMeaning
[[:alnum:]]Alphanumeric (≡ [0-9A-Za-z])
[[:alpha:]]Letter (≡ [A-Za-z])
[[:ascii:]]ASCII (≡ [\x00-\x7F])
[[:blank:]]Space or tab (≡ [\t ])
[[:cntrl:]]Control chars (≡ [\x00-\x1F\x7F])
[[:digit:]]Digit (≡ [0-9])
[[:graph:]]Visible chars (≡ [!-~])
[[:lower:]]Lowercase (≡ [a-z])
[[:print:]]Printable (≡ [ -~])
[[:punct:]]Punctuation
[[:space:]]Whitespace (≡ [\t\n\v\f\r ])
[[:upper:]]Uppercase (≡ [A-Z])
[[:word:]]Word char (≡ [0-9A-Za-z_])
[[:xdigit:]]Hex digit (≡ [0-9A-Fa-f])