Forum Discussion

CumberlandStree's avatar
CumberlandStree
Active Member II
2 years ago

Liquid Code to Exclude Generic Emails such as Yahoo and Hotmail

Hello (and help)

I am trying to build liquid code that will exclude users who have non-business email addresses (yahoo, gmail, hotmail etc) and include users with certain words in their job titles

I am using the following which is not working. Any ideas where it is going wrong?

Much appreciated

 

{% if {{custom_attribute.${job_level}}} matches regex “director” or

{{custom_attribute.${job_level}}} matches regex “ceo” or

{{custom_attribute.${job_level}}} matches regex “SVP” or

{{custom_attribute.${job_level}}} matches regex “Head of” and 

{{custom_attribute.${email_address}}} does not match regex “yahoo” or

{{custom_attribute.${email_address}}} does not match regex “gmail” or

{{custom_attribute.${email_address}}} does not match regex “aol” or

{{custom_attribute.${email_address}}} does not match regex “hotmail” 

Message to users

{% endif %}

 

  • Also worth adding that this would probably be achieved much cleaner at segment level - not sure if that fits your use case?

    • CumberlandStree's avatar
      CumberlandStree
      Active Member II

      Hi - unfortunately, creating a segment does not work in this instance.

      Thank you for the link to liquid operators

  • bob's avatar
    bob
    Specialist

    You'll also have an issue with the and/or precedence in that liquid. They are evaluated left to right - there's no implied parentheses. You might need to nest the if statements to get the effect you're thinking of.

    The solution doesn't feel great though. I'd suggest some of this logic should be maintained in your CDP (or whatever you have that feeds data into Braze) - then pass cleaner attributes that you can more easily use for segmentation/personalisation.