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 Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors