本文介绍了从kdb中的字符串中提取数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对kdb + q很陌生.我遇到了从字符串中提取数字的问题.
I am quite new to kdb+q. I've come across this problem of extracting a number out of string.
有什么建议吗?
示例:
"AZXER_1234_MARKET" should output 1234 //Assume that there is only one number in the
字符串
推荐答案
提取数字,然后转换为所需的类型.
Extract the numbers then cast to required type.
q){"I"$x inter .Q.n} "AZXER_1234_MARKET"
1234i
q){"I"$x inter .Q.n} "AZXER_123411_MARKET"
123411i
q){"I"$x inter .Q.n} "AZXER_1234_56_MARKET"
123456i
q){"I"$x inter .Q.n} "AR_34_56_MAT"
3456i
这篇关于从kdb中的字符串中提取数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!