Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kusto query language split @ character and take last item

If I have a string for example: "this.is.a.string.and.I.need.the.last.part" I am trying to get the last part of the string after the last ".", which in this case is "part" How to I achieve this? One way I tried was to split the string on ".", I get a array back, but then I don't know how to retrieve the last item in the array.

| extend ToSplitstring = split("this.is.a.string.and.I.need.the.last.part", ".") 

gives me:

["this", "is","a","string","and","I","need","the","last", "part"]

and a second try I have tried this:

| extend ToSubstring = substring(myString, lastindexof(myString, ".")+1)

but Kusto do not have a function of lastindexof.

Anyone with tips?

like image 464
user1702369 Avatar asked Feb 02 '26 11:02

user1702369


1 Answers

you can access the last member of the array using a negative index -1.

e.g. this:

print split("this.is.a.string.and.I.need.the.last.part", ".")[-1]

returns a single table, with a single column and a single record, with the value part

like image 169
Yoni L. Avatar answered Feb 05 '26 02:02

Yoni L.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!