If you’re looking to add some advanced filters in Google Analytics for example, you’ll no doubt need to use Regex Characters from time to time to filter out items appropriately. This is more for my reference than anything else (the scrap of paper with this stuff noted down is getting scruffy now…) but feel free to use for your own work!
Some examples of when these characters need to be used, is for example if you need to filter out URLs which end in numbers – for example a client site of mine: their products URLs end in numbers, so to determine some figures from Product Pages specifically, I could use \d$ to filter results to only show URLs ending in a number.
Anyway, without further ado:
|Dot .||Match any similar character|
|Backslash \||Ignore the following Regex character||\.html – Allows the dot in .html to be used.|
|Square Brackets [ ]||Match one item in this character set||[uU][sS][aA] – would match both USA and/or usa.|
|Question Mark ?||Match zero or one of the previous item||31? – would match both 3 and 31.|
|Plus Sign +||Match one or more of the previous item||31+ – would match 31, 311, 3111, etc.|
|Asterix *||Match zero or more of the previous item||31* – would match 3, 31, 311, etc.|
|Round Brackets ( )||Group and remember contents as an item|
|Vertical Line |||Either or||html|php – would match files using html or php extensions.|
|Caret ^||Start of a string||^test – matches “test site” but not “a test site”|
|Dollar Sign $||End of a string||site$ – matches “test site” but not “site test”|
|\d||Match any number|
|\s||Match any whitespace|
|\w||Match any letter/number/underscore|
By all means this list is not complete, but it’s complete enough to fulfill my needs as an SEO – I’ve never needed any Regex characters outside of this list, so in that regard it seems fine. However please, if you think something in this table is incorrect or something needs adding, tell me and I can get it sorted.