[UA] Question mark (?), plus sign (+), asterisk (*)

Question mark (?)

The question mark (?) matches the preceding character 0 or 1 times.

For example, 10? matches:

  • 1
  • 10
Example

Match an IP address with 1 or 2 digits in the last section.

For example, 216\.239\.32\.\d\d? matches:

  • 216.239.32.2
  • 216.239.32.34

This example uses the backslash to escape the decimal, and uses \d to match any digit.

Plus sign (+)

The plus sign (+) matches the preceding character 1 or more times.

For example, 10+ matches:

  • 10
  • 100
  • 1000
  • etc.
Example

Match an IP address with 1 or more digits in the last section.

For example, 216\.239\.32\.\d+ matches:

  • 216.239.32.2
  • 216.239.32.34
  • 216.239.32.567

This example uses the backslash to escape the decimal, and uses \d to match any digit.

Asterisk (*)

The asterisk or star matches the preceding character 0 or more times.

For example, 10* matches:

  • 1
  • 10
  • 100
  • 1000
  • etc.
Example

Match an IP address with 1 or more digits in the last section.

For example, 216\.239\.32\.\d* matches

  • 216.239.32.2
  • 216.239.32.34
  • 216.239.32.567

This example uses the backslash to escape the decimal, and uses \d to match any digit.

If you need to match more than just the preceding item, you can combine the asterisk with the dot (.*). The dot matches any preceding item, and then the asterisk will match that item zero or more times, which lets you match things like all URIs that begin and end with the same characters, regardless of how many characters are in between. For example, /mens/.*html matches:

  • /mens/shirts/oxford.html
  • /mens/shirts/oxford/shortsleeve.html

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Search
Clear search
Close search
Google apps
Main menu
16494018034862725747
true
Search Help Center
true
true
true
true
true
69256
false
false