Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

M Language - Retrieve String of Contiguous Numbers from a String

Hello everyone, Is there a way  to retrieve a string of  contiguous numbers from a string ? The only requirement is that the numeric characters are contiguous.   Let me illustrate: 1) ABCDE234 -...
  • smpa01's avatar
    7 years ago

    Anonymous By the way there is also a R solution to this problem.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRydnE1MjZRitUBc0xMzXRdXMA8Q2MToICuszOY5+ysa2piHO/mBuUBWbrGxkDl5kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
        #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)x<-dataset#(lf)x#(lf)library(stringr)#(lf)numextract <- function(string){str_extract(string, ""\\d+\\.*\\d*"")}#(lf)x$result<-as.numeric(numextract(x$Column1))",[dataset=#"Changed Type"]),
        #"""x""" = #"Run R script"{[Name="x"]}[Value]
    in
        #"""x"""