Forum Discussion

afhealey's avatar
afhealey
Frequent Visitor
5 years ago
Solved

Removing HTML tags and reordering text

Howdy folks, I have a situation where a text string is being imported that could contain hyperlinks (it might not contain any, or it could contain several). What I want to do is extract the text and...
  • v-yingjl's avatar
    5 years ago

    Hi afhealey ,

    You can splilt column many times by specific string and filter the specfic string to achieve this in power query. The whole query would be like this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOLgBTqSEZmcUKQFScn5uqUJJaUQKR1YdKx+ShqIZwEhUyilLTbGOUMkpKCqz09cvLy/XS8/PTc1L1kvNzY5QUilJzgLJ5+Wn5OTn55TEQG1PdwUoUcjLzsqGWJCKbisNKBTIdlJSZlw5yjj5O9zgBVRB0jVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Data", type text}}),
        #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Data", Splitter.SplitTextByDelimiter("<p>", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Data"),
        #"Split Column by Delimiter1" = Table.ExpandListColumn(Table.TransformColumns(#"Split Column by Delimiter", {{"Data", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Data"),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Data", type text}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.Contains([Data], "href")),
        #"Split Column by Delimiter2" = Table.ExpandListColumn(Table.TransformColumns(#"Filtered Rows", {{"Data", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Data"),
        #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Data", type text}}),
        #"Filtered Rows1" = Table.SelectRows(#"Changed Type2", each not Text.Contains([Data], "href"))
    in
        #"Filtered Rows1"

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.