Question mark (?)
The question mark (?) matches the preceding character 0 or 1 times.
For example, 10? matches:
- 1
- 10
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.
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.
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