Skip to main content
A regular expression is a pattern that matches text against a set of rules instead of a single exact string. Use a regular expression when a condition needs to match multiple variations of a URL, such as different query parameters or page numbers, rather than one exact address. Kameleoon conditions that offer a matches the regular expression operator use the syntax on this page, including segment conditions like Landing page URL and Referring website URL, goal URL conditions, and advanced targeting tools like acquisition channels and key pages.

Regular expression syntax

  • . matches any single character. For example, Kamele.on matches Kameleoon, Kamele0n, and Kamele8on.
  • * matches the preceding character zero or more times. For example, Kameleoo*n matches Kameleon, Kameleoon, and Kameleooon.
  • ? matches the preceding character zero or one time. For example, Kameleoo?n matches Kameleon and Kameleoon.
  • + matches the preceding character one or more times. For example, Kameleo+n matches Kameleoon and Kameleoooon.
  • | acts as an OR operator between two patterns. For example, Kameleoon|Chameleoon matches Kameleoon or Chameleoon.
  • ^ matches the start of the string. For example, ^Kameleoon matches URLs starting with Kameleoon.
  • $ matches the end of the string. For example, Kameleoon$ matches URLs ending with Kameleoon.
  • () groups several elements, usually combined with |. For example, Kameleoon (AB Testing|Conversion) Tool matches Kameleoon AB Testing Tool or Kameleoon Conversion Tool.
  • [] matches any single character inside the brackets. For example, /Kameleoon/[234] matches Kameleoon 2, Kameleoon 3, and Kameleoon 4.
  • - defines a range inside []. For example, /kameleoon/[2-9] matches every page from Kameleoon 2 to Kameleoon 9.
  • {} sets a minimum and maximum number of repetitions of the preceding character. For example, Kameleo{2,4}n matches Kameleoon, Kameleooon, and Kameleoooon.
Escape special characters (for example, ,, ., *) with a backslash: \,, \., \*.
Regular expressions are case-sensitive.

Examples

  • ^.{10}$ matches URLs containing exactly 10 characters.
  • general\.(html|php)$ matches URLs ending with either general.php or general.html.
  • /fr/ matches URLs containing /fr/.
  • /annexes/.*\d{3} matches URLs containing the fragment /annexes/ and a three-digit number.
  • /annexes/.*\d{2}.*test.html$ matches URLs containing the fragment /annexes/, a two-digit number, and ending with test.html.