Forum Moderators: DixonJones
So I get it basically about regular expressions but I don't quite know how to apply them to Google Analytics other than just a cook-book application - say as applied on the Lunametrics site or in Brian Clifton's book about same.
Let's say I want to find the occurrence of the term Dr. (with or without the period) in either search history or content viewing using the "Find" box at the bottom of a GA page.
I type in "DR" and I get all instances of DR, such as in Andrew. How do I filter out other instances of DR but only when it is used to mean as a title, say a medical doctor?
Of course DR. also doesn't work, nor does DR with a space.
Thanks,
-C
\bdr\.?\b
That will find only dr and dr. In PCRE flavor of regex, you can also set case insensitivity with i flag. If not available, you can make character classes, in which case
\b[dD][rR]\.?\b
That find all case combos (though dR is unlikely!).
Final alternative
\b(Dr¦DR¦dr)\.?\b
Which finds only the three options listed
Yes, thanks for remembering that!
>>Amazing!
I'm glad you share my sense of wonder at the power of regex. I tried to get a seminar of historians to understand why they absolutely had to learn them in order to find textual variants in old documents. They were blown away by some sample searches on a large corpus of texts, but I could see in their eyes that 30 minutes later not a one of them would know what a regex was.