Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pentester
New Member

Extract a pattern of type X.Y or X.Y.Z or X.Y.Z.T in a character string where X,Y,Z,T are numbers.

Hello community,

 

I would like to extract the software version in a field containing the software name and the version in X.Y or X.Y.Z or X.Y.Z.T format. Could anyone help me?

 

Below is an example of data and the expected result.

 

NAMEVERSION
Notepad 3.953.95
Kali 2024.1 (64 bit)2024.1
Microsoft .NET Runtime - 6.0.9 (x64)6.0.9
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.179.0.30729.17
Microsoft SQL Server 2016 
1 ACCEPTED SOLUTION
Syk
Super User
Super User

First, lets duplicate the column. Right click > Duplicate Column

Syk_0-1709744782117.png

Now we will split the new column by a demiliter at each occurence (space). Transform > Split column > by delimiter

Syk_1-1709744854122.png

Now we have a number of columns with junk but some of them will have the version.

Syk_2-1709744952971.png

Select your name column and Transform > Unpivot Columns > Unpivot Other Columns

Syk_3-1709745001945.png

Then filter your value column to include a period but not include NET

Syk_4-1709745036391.png

 

 

And you're left with just the version!

Syk_5-1709745060481.png

 

 

 

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi @Pentester, single step solution:

 

dufoq3_0-1710086225111.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcy9DoIwGIXhWznphEGb8mOxs3FSSQTjQhhaqMmXoJhSjJdvdWQ+532ahpWjty/dI+Nqy9p1w456IKQizXmCSOYw5Ff/4UydG6fx7sHLwxXV/PT0sNhAcsEVoo/Ml8cbTbMesI/jIIodKtvT5B2Z2Wsz/NoQQYU+E0WqeFIsgPpyQm3d27oAJJK17Rc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t]),
    Ad_Version = Table.AddColumn(Source, "Version", each
      [ a = Splitter.SplitTextByCharacterTransition((x)=> not List.Contains({"0".."9"}, x), (y)=> not List.Contains({"0".."9"}, y))([NAME]),
        b = List.Transform(a, (x)=> Text.Trim(x)),
        c = List.Select(b, (x)=> List.ContainsAny(Text.ToList(x), {"0".."9"}) and Text.Contains(x, ".")),
        d = List.TransformMany(c, (a)=> {List.Transform(Text.Split(a, " "), (b)=> Text.ToList(Text.Lower(b)))} , (x,y)=> List.Transform(List.Select(y, (c)=> not List.ContainsAny(c, {"a".."z"})), Text.Combine){0}? ){0}?
      ][d], type text)
in
    Ad_Version

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Syk
Super User
Super User

First, lets duplicate the column. Right click > Duplicate Column

Syk_0-1709744782117.png

Now we will split the new column by a demiliter at each occurence (space). Transform > Split column > by delimiter

Syk_1-1709744854122.png

Now we have a number of columns with junk but some of them will have the version.

Syk_2-1709744952971.png

Select your name column and Transform > Unpivot Columns > Unpivot Other Columns

Syk_3-1709745001945.png

Then filter your value column to include a period but not include NET

Syk_4-1709745036391.png

 

 

And you're left with just the version!

Syk_5-1709745060481.png

 

 

 

Thank you very much SyK. It perfectly meets my needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors