azure - Kusto 查询语言拆分@字符并取最后一项
问题描述
如果我有一个字符串,例如:“this.is.a.string.and.I.need.the.last.part”我试图在最后一个“.”之后获取字符串的最后一部分,在这个案例是“部分”我如何实现这一目标?我尝试的一种方法是在“。”上拆分字符串,我得到一个数组,但是我不知道如何检索数组中的最后一项。
| extend ToSplitstring = split("this.is.a.string.and.I.need.the.last.part", ".")
给我:
["this", "is","a","string","and","I","need","the","last", "part"]
第二次尝试我试过这个:
| extend ToSubstring = substring(myString, lastindexof(myString, ".")+1)
但是 Kusto 没有 lastindexof 的功能。
有人有提示吗?
解决方案
您可以使用负索引访问数组的最后一个成员-1
。
例如这个:
print split("this.is.a.string.and.I.need.the.last.part", ".")[-1]
返回单个表,具有单列和单条记录,其值为part
推荐阅读
- java - 是否可以在 Docker 容器中使用 whatsapp web?
- python - 在 python 上找不到用于导入 csv 的文件。文件路径正确,一切都安装好了
- r - 逆向工程累积到每日数据?
- javascript - 根据具有多个 .where 的过滤查询从集合 Cloud Firestore 中获取值
- c++ - 使用变音符号迭代字符串时出现问题
- python - 在 Python 中制作令牌
- python - Networkx:如何为一次绘制多棵树指定多个根?
- c - 斐波那契数列的项可以是负数吗?
- node.js - Node.js http.createServer 实际是如何工作的?
- c# - Visual Studio 在包管理器控制台运行脚本迁移时崩溃