let
extractNumber = (this as text) as text =>
let
digits = {"0","1","2","3","4","5","6","7","8","9"},
pos = Text.PositionOfAny(this,digits,Occurrence.First),
len = Text.Length(this)
in
Text.Range(this,pos,len-pos)
in
extractNumber("INF102245")
let
extractNumber = (this as text) as any=>
let
chars = {"a".."z"},
pos = Text.PositionOfAny(Text.Lower(this),chars,Occurrence.Last) + 1,
len = Text.Length(this)
in
Text.Range(this,pos,len-pos)
in
extractNumber("IN98F102245")
let
extractNumber = (this as text) as any=>
let
chars = {"a".."z"},
pos = Text.PositionOfAny(Text.Lower(this),chars,Occurrence.Last) + 1,
len = Text.Length(this)
in
Text.Range(this,pos,len-pos),
demoTable = Table.FromColumns({ {"IFT12345","I12FT345","IF123T45"} },{"TextAndNumbers"}),
lastNumbers = Table.AddColumn(demoTable,"lastNumber", each extractNumber([TextAndNumbers]))
in
lastNumbers
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Result = Table.AddColumn(Source, "Custom", each Text.End([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]],Text.Length([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]])-Text.PositionOfAny([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]],{"a".."z","A".."Z"},Occurrence.Last)-1))
in
Result
Helo,
another solution
Code:let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], Result = Table.AddColumn(Source, "Custom", each Text.End([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]],Text.Length([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]])-Text.PositionOfAny([[COLOR=#333333][FONT=Verdana]Body[/FONT][/COLOR]],{"a".."z","A".."Z"},Occurrence.Last)-1)) in Result