cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerBtm
New Member

Match strings only composed of digits or letters, and remove the unwanted chars?

Hi! I need some help with Powerquery. I'm trying to remove all extraneous characters from a given input string so that there are only digits and letters left, but I don't really know if that's possible without access to regex. Does anyone have any ideas?

1 ACCEPTED SOLUTION
CNENFRNL
Super User III
Super User III

Simple enough,

 

= Text.Select("!~cl3509af;J8Ea""@6O4c", {"0".."9","a".."z","A".."Z"})

 

Screenshot 2021-06-08 224215.png

View solution in original post

2 REPLIES 2
CNENFRNL
Super User III
Super User III

Simple enough,

 

= Text.Select("!~cl3509af;J8Ea""@6O4c", {"0".."9","a".."z","A".."Z"})

 

Screenshot 2021-06-08 224215.png

View solution in original post

AlB
Super User III
Super User III

Hi @PowerBtm 

Place the following M code in a blank query to see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKix3UDY0MlZxC1KKjQUA", 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 List.Select(Text.ToList([Column1]), each List.Contains({"A".."Z"} & {"a".."z"} & {"0".."9"}, _))),

    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From)), type text})
in
    #"Extracted Values"

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors