Skip to main content

Regular expressions

Kameleoon lets you target URLs using regular expressions.

Here is a detailed list of the most used regular expressions:

  • . = Replace one character with another in your regular expression. For example, the expression Kamele.on will target URLs containing Kameleoon, Kamele0n, Kamele8on, etc.
  • * = Delete the previous character or add the same character after. For example, the expression Kameleoo*n, will target URLs containing Kameleon, Kameleoon, Kameleooon, etc.
  • ? = Delete or leave the previous character. For example, Kameleoo?n will target URLs containing Kameleon and Kameleoon.
  • + = Add the previous character once or several times. For example, Kameleo+n will target URLs containing Kameleoon and Kameleoooon.
  • | = Target several chains of characters. It is like an "Or" operator. For example, Kameleoon|Chameleoon will target Kameleoon or Chameleoon.
  • ^ = Targets the chain's beginning. ^Kameleoon will target URLs starting with Kameleoon.
  • $ = Targets the chain's end. Kameleoon$ will target URLs ending with Kameleoon.
  • () = Creates groups of several elements. This regular expression is usually combined with |. For example, Kameleoon (AB Testing|Conversion) Tool will target Kameleoon AB Testing Tool or Kameleoon Conversion Tool.
  • [] = Will target each character inside the []. For example, /Kameleoon/[234] will target Kameleoon 2, Kameleoon 3 and Kameleoon 4.
  • - = /kameleoon/[2-9] will target every page from Kameleoon 2 to Kameleoon 9.
  • {} = Defines character instance limits. For example, Kameleo{2,4}n will target URLs containing Kameleoon, Kameleooon, or Kameleoooon.
note

If your character chain contains a special character (for example, ,, ., *), add a backslash \ before it.

note

These expressions are case-sensitive.

Here are some examples of regular expressions:

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