如何从 Azure 数据工厂中具有动态长度的字符串中删除最后三个字符?

How to remove the last three characters from a string with a dynamic length in Azure Data Factory?

我在 Azure 数据工厂 (v2) 中有一个字符串变量,我想从中删除最后 3 个字符。最初我以为使用子字符串操作,它需要 startIndex 和 length 参数。但是,startIndex 可能会有所不同,因为字符串没有固定长度。关于如何解决这个问题有什么建议吗?

示例,删除最后 3 个字符,字符串长度变化:

'abcdef' -> 'abc'
'helloworld' -> 'hellowo'
'2020_18' -> '2020'
  1. 我们可以使用length函数来获取字符串的长度。

  2. 然后我们可以使用substring函数,表达式如substring('String',0, length-3).

  3. 在ADF中,我们可以使用表达式@substring('helloworld',0,sub(length('helloworld'),3))删除最后3个字符