Numbers (digits) are represented by the character d
, whereas letters (words) are represented by the character w
in regular expressions.
Digits
We also use backslashes with \d
and \w
- this tells the computer you want to use the d and w as part of the regular expression, not as part of the search:
product-\d\.html
will give you
- product-0.html
- product-1.html
- product-2.html
- ...
- product-9.html
Remember that \d
is only for a *single* digit, so if you wanted to have longer numbers, you would use this:
product-\d+\.html
This tells a computer to match any digit, at least one digit. So the results from this search would get you
- product-0.html
- product-1.html
- product-2.html
- product-10.html
- product-2450.html
- ...
and so on.
To use this example, you would add the following to your regex fields: Subdomain: TLD: Path: |
Word Characters
Say you want to target pages with human-readable names that don't use special characters. Maybe these are photo album folders, or documents that your users have created, or product pages that include the name and ID of the product. We can do this easily by using the \w function:
\w+\.php
This will match any file with only word characters (a-z, A-Z and _) in the name. Here are some example files that this regex will match:
- paris.php
- Melbourne.php
- McMurdo_Field_Work_Presentation.php
- premium_plan_2016Sept.php
- loflo_washer_23998.php
To use this example, you would add the following to your regex fields: Subdomain: TLD: Path: |
Back to the beginning - Previous - Next
Comments
0 comments
Article is closed for comments.