如何从字符串中提取数字

詹森

我有一个像“公司间债权人{DEMO[[1]]}”这样的字符串。我只想从字符串中提取数字,例如只是“1”。

如何在 Invantive SQL 中做到这一点?

帕特里克·霍夫曼

您应该能够使用substr(从文本中的特定位置获取一些文本)和instr(从其他文本中的特定文本中获取位置):

select substr
       ( d
       , instr(d, '[[') + 2
       , instr(d, ']]') - instr(d, '[[') - 2
       )
from   ( select 'intercompany creditors {DEMO[[1]]}' d 
         from dual@DataDictionary
       ) x

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章