The question mark is one of the most versatile characters in regular expressions. It is used to mean that whatever came before it is optional - there can be 0 or 1 occurrence.
You can use it for single characters:
products?
will match product
and products
Or for whole words by using parentheses:
(an)?droid
will match android
and droid
Example: Targeting the www Subdomain
Some websites are set up so that you can go to both www.site.com and site.com. If you use the Simple URL targeting field, our system takes care of that automatically. But if you use a regex on a website like this, you will need to use the question mark to make sure pages on the www.site.com version show up.
To use this example, you would add the following to your regex fields: Subdomain: TLD: Path: |
This will target http://www.site.com and http://site.com.
If your website always uses www, make sure to add www
in the Subdomain field.
To use this example, you would add the following to your regex fields: Subdomain: TLD: Path: |
Note: You will not have to escape the period after the "www" - our system takes care of that for you.
Comments
0 comments
Article is closed for comments.