13.07.2015 Views

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

groupingsquArE BraCkeTs&daShesI usually like to introduce just <strong>on</strong>e character at atime. But these two are a little like salt and pepper. True, you canuse just salt or just pepper, but they get served together so oftenthat they are a set. And so we have both square brackets [ ] anddashes –With square brackets, you can make a simple list, like this: [aiu] .This is a list of items and includes three vowels <strong>on</strong>ly. Note: Unlesswe use other expressi<strong>on</strong>s to make this more complicated, <strong>on</strong>ly <strong>on</strong>eof them will work at a single time.So p[aiu]n will match pan, pin and pun. But it will not matchpain, because that would require us to use two items from the[aiu] list, and that is not allowed in this simple example.You can also use a dash to create a list of items, like this:[a-z] – all lower-case letters in the English alphabet[A-Z] – all upper-case letters in the English Alphabetpt. 1[a-zA-Z0-9] – all lower-case and upper-case letters, and digits.(Notice they are not separated by commas.)Dashes are <strong>on</strong>e way of creating a list of items quickly, as you cansee above.[-]a D va N Ced tI pCharacters that are usually special, like $ and ?, no l<strong>on</strong>ger arespecial inside of square brackets. The excepti<strong>on</strong>s are the dash,the caret (more <strong>on</strong> this <strong>on</strong>e later) and the backslash, which stillworks like all backslashes do inside the square brackets.12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!