Forum Discussion

cannellonigreyh's avatar
cannellonigreyh
Frequent Visitor
3 years ago
Solved

How to remove multiple email addresses

Hello. 

 

A field (emailBody) contains the body/text of certain emails we have received. 

In Power Query, I need to remove/obscure email addresses for data protection reasons. 

One entry can contain multiple email addresses. 

 

I've found this solution here

 

 

= Text.Combine(List.Select(Text.Split([Name], " "), each not(Text.Contains(_, "PL"))), " ")

 

 

...but I understand this would only work for one email address for each entry. 

 

How can I remove any string that is like '*@*' ?

 

  • AntrikshSharma's avatar
    AntrikshSharma
    3 years ago

    cannellonigreyh You can use this:

    AddedCustom = 
        Table.AddColumn ( 
            PreviousStep, 
            "New Text", 
            each 
            Text.Combine ( 
                List.Select ( 
                    Text.Split ( [Text], " " ), 
                    each not Text.Contains ( _, "@" ) 
                ), 
                " " 
            ), 
            type text 
        )

4 Replies

    • cannellonigreyh's avatar
      cannellonigreyh
      Frequent Visitor

      Input: 

      Row 1: Hi my name is Tom and my email address is [email protected] I would like to discuss the price of brake fluid. 

      Row 2: My brother's email address is [email protected] and mine is [email protected] and I am very happy because biscuits exist. 

       

      Output: 

      Row 1: Hi my name is Tom and my email address is I would like to discuss the price of brake fluid. 

      Row 2: My brother's email address is  and mine is  and I am very happy because biscuits exist. 

       

       

      • AntrikshSharma's avatar
        AntrikshSharma
        Community Champion

        cannellonigreyh You can use this:

        AddedCustom = 
            Table.AddColumn ( 
                PreviousStep, 
                "New Text", 
                each 
                Text.Combine ( 
                    List.Select ( 
                        Text.Split ( [Text], " " ), 
                        each not Text.Contains ( _, "@" ) 
                    ), 
                    " " 
                ), 
                type text 
            )