Forum Discussion
Power Query Replace using Wildcards ie Replace in Excel <*> with space
- 1 year ago
this
let fx = (txt) => Text.Combine( List.Alternate( List.Select(Text.SplitAny(txt, "<>"), (x) => x <> ""), 1, 1, Number.From(not Text.StartsWith(txt, "<")) ), " " ), Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content], result = Table.TransformColumns(Source, {"Column1", fx}) in resultreplaces <, > and everything in between with space. If you don't need space - simply remove " " in Text.Combine call.
- Anonymous1 year ago
Hi,
Thanks for the solutions everyone offered, and i want to offer some more information for user to refer to.
hello BZimber , you can create a blank query, and put the following code to advanced editor in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOTsksAzNSE5OSISL6cKGU1DSlWB2YSoQ4mk5DI2MTUzO4oEJxSWVOqm2MUlJ+hW5xZlVmXrpVUn5RSmqRLlDEOgZiXKpSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let a=Text.Split([Column1],">"), b=List.Transform(a,each if Text.Contains(_,"<") then Text.BeforeDelimiter(_,"<") else _), c=Text.Combine(b," ") in c), #"Trimmed Text" = Table.TransformColumns(#"Added Custom",{{"Custom", Text.Trim, type text}}) in #"Trimmed Text"Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Text.BetweenDelimiters might be helpfull
It might very well be helpful. However I am a new user and I don't have the first clue on what to do or how to use that function as I am not to the level of coding. I am learning via videos using the built in function buttons that create code. I am not to the level yet to speak 'm' code.
- Omid_Motamedise1 year ago
Super User
imagine your data are on a coluumn namely X, then add a new custom column namely X2 by the next formula to extract the text between <>.
=Text.BetweenDelimiter([X],"<",">")
then replace it by your desired text by using Text.Replace