Forum

Extract code from s...
 
Notifications
Clear all

Extract code from string in a cell

2 Posts
2 Users
0 Reactions
39 Views
(@erik_h_dk)
Posts: 43
Trusted Member
Topic starter
 

Hi to all of you

At work my boss has challenged me to extract a code from a string in a cell. 

The code is like 4 characters (can be letters and numbers)-5 numbers-5 numbers-year (2 numbers)

Example: AB42-12345-54615-25. Letters can be upper and/ or lower case.

In most cases the code has text and or numbers before and after - and always parted with a space on either side. 

Example - "this is a test AB42-12345-54615-25 sold august 30. 2025"

Can any of you help me - in Power Query or otherwise to extract the code to a new column ?

In this example it would be - "AB42-12345-54615-25"

 

At work the file has 100.000 plus rows, so it will save me a lot of time.

 

Thank you

Erik

 

 

 
Posted : 30/08/2025 9:17 pm
Riny van Eekelen
(@riny)
Posts: 1298
Member Moderator
 

@erik_h_dk

Must you do this in PQ?

Quite easy to do it in Excel. Have a look at the attached. Not very difficult to replicate this in PQ as well. Find the location of the first "-", minus 4 and then extract the next 19 characters.

 
Posted : 31/08/2025 3:39 am
Share: