Skip to content

Using Capturing Groups

By encasing sections of a regular expression with parentheses, you can extract and reference specific subpatterns. Known as "capturing groups", these value groups can then be referenced using $ followed by the group's number, starting from 1.

JSON Capturing Groups

TIP

To test your regular expressions, visit regex101.com.

To capture key-value string pairs from JSON such as:

json
{"key":"value"}

With the Matcher set to Regex, type the following regular expression in the input field:

regex
\{\"([^\"]+)\":\"([^\"]+)\"\}

To reference the capturing groups in the Replacer input field, select Term and use:

  • $1 to reference key.
  • $2 to reference value.

NOTE

Caido does not currently support look-around and backreference regular expressions.

Using capturing groups for replacement.

TIP

To use $ and an integer literally, escape the $ with another $:

{"$$1":"$2"} becomes {"$1":"value"}.