Regex for Looker Studio: Resources
Useful Regex
Identify social media sources:
(?i).*(facebook|fb|twitter\.com|linkedin|youtube|reddit|instagram|ig|vkontakt|blogger\.com|pinterest|tiktok|snapchat|threads\.net|discord\.com|whatsapp|quora|tumblr|vk\.com).*|x\.com|t\.co
Match all AI sources
.*(\.ai$|copilot|chatgpt|openai|perplexity|bard\.google|gemini|claude|groq|\.metaai|you\.com).*
Count when variable contains
sum(case when REGEXP_Contains(variable,’Converted|Pending’) then 1 else 0 end)
Extract the top level of the landing page
REGEXP_EXTRACT(Landing page,'([^:/?\n]+)’)
Extract top level directory from full URL
REGEXP_EXTRACT(Page location, “^https://[^/]+/([^/]+)/“)
Extract second level category from full URL
REGEXP_EXTRACT(Page location,’^https://[^/]+/[^/]+/([^/]+)/‘
Regex resources
Regex101’s build and test tool