You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在OIC中提取URL末尾的invoiceInstallmentUniqId值?

在OIC中提取URL末尾的唯一ID值

问题场景

给定URL:

https://test.com:111/fscm/resources/11.13.18.05/invoices/11111/child/invoiceInstallments/
00030000000SDSDD00057708000000000000CB2F0000000SDSC000577080

需要提取末尾的00030000000SDSDD00057708000000000000CB2F0000000SDSC000577080作为invoiceInstallmentUniqId。

解决方案

以下是几种在OIC中实现的可行方法:

方法1:使用XPath的tokenize+last()函数

在OIC的表达式编辑器中,通过XPath字符串拆分函数直接获取目标值:

tokenize(normalize-space($your-url-variable), '/')[last()]
  • 逻辑:先用normalize-space去除URL中的换行、空格等空白字符,再用tokenize按/分割成字符串序列,最后用last()取序列的最后一个元素,即为目标ID。

方法2:使用OIC内置substring-after-last函数

OIC提供了专门的内置函数简化操作:

substring-after-last(normalize-space($your-url-variable), '/')
  • 逻辑:substring-after-last会定位到URL中最后一个/,直接返回其后方的内容,配合normalize-space处理格式问题。

方法3:Groovy脚本(适配复杂格式场景)

如果需要更灵活的文本处理,可添加Groovy脚本步骤:

def rawUrl = "https://test.com:111/fscm/resources/11.13.18.05/invoices/11111/child/invoiceInstallments/\n00030000000SDSDD00057708000000000000CB2F0000000SDSC000577080"
def cleanedUrl = rawUrl.replaceAll("\\s", "") // 清除所有空白字符
def urlParts = cleanedUrl.split("/")
def invoiceInstallmentUniqId = urlParts[-1] // 取数组最后一位元素
return invoiceInstallmentUniqId
  • 逻辑:先清理URL中的格式干扰字符,再按/拆分后提取最后一段内容。

可根据你的OIC流程场景选择对应方法实现。

内容的提问来源于stack exchange,提问作者user16514999

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 17:40:48