Google Tag Manager

Forum Discussion

EmPaulin's avatar
EmPaulin
Practitioner III
8 months ago

REGEX - best use cases

I've been using Regex for locating emails (particularly invalid ones) 

but any other more advanced uses that you might have for Regex? 

would love to hear / read about them. 

  • Joseph_C's avatar
    Joseph_C
    Practitioner II

    Maybe not "advanced" but I used regex a lot to build target audiences based on attributes using strings.

    We had custom attributes like `favorite_location` stored like:`San Francisco, CA, Dalas, Tx, Texas, Carthage, NY`
    Building the audience, I could copy and paste a list: `San Francisco|Palo Alto|Oakland` so that I didn't need to select hundreds. Or just to target everyone in California, I'd set regex = `,\sCA`. 




  • There's a whole world of regex code out there that I'd love to get better at. I do think that there are potentially some really cool segmenting opportunities given the regex filter, BUT, I also don't think we're missing out on too much by not being a regex expert. Or if regex is truly necessary for specific segmenting, there may also be room for improvement in how the data is being ingested.