在设定位置提取字符 [英] Extract characters at a set position
本文介绍了在设定位置提取字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一个函数来提取字符串中特定位置的字符.例如,我有一个带有日期的长文件名,而我只想以日期结尾:
I am trying to find a function that will extract characters at a certain position within a string. For example, I have a long file name with a date in it, and I want to end up with only the date:
'LT50420331984221PAC00_B7.tif'
我只想要1984221"部分.我想出了一个复杂的函数,但想知道是否有更优雅的解决方案.
and I want only the '1984221' portion. I've come up with a complicated function, but was wondering if there is a more elegant solution.
推荐答案
如果您知道日期在字符串中的确切位置,您可以使用
If you know the exact position of the date in your string you can use
substr('LT50420331984221PAC00_B7.tif', 10, 16)
这篇关于在设定位置提取字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文