Home

Scalar function request: lastindexof

%3CLINGO-SUB%20id%3D%22lingo-sub-663002%22%20slang%3D%22en-US%22%3EScalar%20function%20request%3A%20lastindexof%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-663002%22%20slang%3D%22en-US%22%3E%3CP%3E%3CI%3Edocumentation%20copied%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Findexoffunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eindexof%3C%2FA%3E%3C%2FI%3E%3C%2FP%3E%3CH1%20id%3D%22toc-hId-1961241760%22%20id%3D%22toc-hId-1961241762%22%3Elastindexof()%3C%2FH1%3E%3CP%3EFunction%20reports%20the%20zero-based%20index%20of%20the%20last%20occurrence%20of%20a%20specified%20string%20within%20input%20string.%3C%2FP%3E%3CP%3EIf%20lookup%20or%20input%20string%20is%20not%20of%20string%20type%20-%20forcibly%20casts%20the%20value%20to%20string.%3C%2FP%3E%3CP%3E%3CSTRONG%3ESyntax%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Elastindexof(%3CEM%3Esource%3C%2FEM%3E%2C%3CEM%3Elookup%3C%2FEM%3E%5B%2C%3CEM%3Estart_index%3C%2FEM%3E%5B%2C%3CEM%3Elength%3C%2FEM%3E%5D%5D)%3C%2FP%3E%3CP%3E%3CSTRONG%3EArguments%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CEM%3Esource%3C%2FEM%3E%3A%20input%20string.%3C%2FLI%3E%3CLI%3E%3CEM%3Elookup%3C%2FEM%3E%3A%20string%20to%20seek.%3C%2FLI%3E%3CLI%3E%3CEM%3Estart_index%3C%2FEM%3E%3A%20search%20start%20position%20(optional).%3C%2FLI%3E%3CLI%3E%3CEM%3Elength%3C%2FEM%3E%3A%20number%20of%20character%20positions%20to%20examine%20(optional).%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EReturns%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EZero-based%20index%20position%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Elookup%3C%2FEM%3E.%3C%2FP%3E%3CP%3EReturns%20-1%20if%20the%20string%20is%20not%20found%20in%20the%20input.%3C%2FP%3E%3CP%3EIn%20case%20of%20irrelevant%20(less%20than%200)%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Estart_index%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Elength%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameter%20-%20returns%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Enull%3C%2FEM%3E.%3C%2FP%3E%3CP%3E%3CSTRONG%3EExamples%3C%2FSTRONG%3E%3C%2FP%3E%3CPRE%3E%20print%20idx1%20%3D%20lastindexof(%22%2Fabc%2Fcde%2Ffgh%22%2C%20%22%2F%22)%20%2F%2F%20lookup%20found%20in%20input%20string%0A%20%2C%20idx2%20%3D%20lastindexof(%22%2Fabc%2Fcde%2Ffgh%22%2C%20%22%2F%22%2C%201%2C%206)%20%2F%2F%20lookup%20found%20in%20researched%20range%0A%20%2C%20idx3%20%3D%20lastindexof(%22%2Fabc%2Fcde%2Ffgh%22%2C%20%22%2F%22%2C%201%2C%202)%20%20%2F%2F%20search%20starts%20from%20index%201%2C%20but%20stops%20after%202%20chars%2C%20so%20full%20lookup%20can't%20be%20found%0A%20%2C%20idx4%20%3D%20lastindexof(%22%2Fabc%2Fcde%2Ffgh%22%2C%20%22%2F%22%2C%200%2C%203)%20%2F%2F%20search%20starts%20after%20occurrence%20of%20lookup%0A%20%2C%20idx5%20%3D%20lastindexof(%22%2Fabc%2Fcde%2Ffgh%22%2C%20%22%2F%22%2C%20-1)%20%2F%2F%20invalid%20input%0A%20%2C%20idx6%20%3D%20lastindexof(1231231%2C%202)%20%2F%2F%20two%20first%20parameters%20were%20forcibly%20cast%20to%20strings%20%221231231%22%20and%20%222%22%3C%2FPRE%3E%3CP%3Eidx1%20idx2%20idx3%20idx4%20idx5%20idx6%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E8%3C%2FTD%3E%3CTD%3E4%3C%2FTD%3E%3CTD%3E-1%3C%2FTD%3E%3CTD%3E0%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E4%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-663002%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Patrick Naughton
Contributor

documentation copied from indexof

lastindexof()

Function reports the zero-based index of the last occurrence of a specified string within input string.

If lookup or input string is not of string type - forcibly casts the value to string.

Syntax

lastindexof(source,lookup[,start_index[,length]])

Arguments

  • source: input string.
  • lookup: string to seek.
  • start_index: search start position (optional).
  • length: number of character positions to examine (optional).

Returns

Zero-based index position of lookup.

Returns -1 if the string is not found in the input.

In case of irrelevant (less than 0) start_index or length parameter - returns null.

Examples

 print idx1 = lastindexof("/abc/cde/fgh", "/") // lookup found in input string
 , idx2 = lastindexof("/abc/cde/fgh", "/", 1, 6) // lookup found in researched range
 , idx3 = lastindexof("/abc/cde/fgh", "/", 1, 2)  // search starts from index 1, but stops after 2 chars, so full lookup can't be found
 , idx4 = lastindexof("/abc/cde/fgh", "/", 0, 3) // search starts after occurrence of lookup
 , idx5 = lastindexof("/abc/cde/fgh", "/", -1) // invalid input
 , idx6 = lastindexof(1231231, 2) // two first parameters were forcibly cast to strings "1231231" and "2"

idx1 idx2 idx3 idx4 idx5 idx6

84-10 4
1 Reply
Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies